Shortcode Builder

Build a shortcode call with its attributes quoted correctly — and, if you want it, the PHP behind it.

Runs on your deviceWordPressWorkingNo account needed

What this tool does

Shortcode Builder takes a tag, a list of attributes and optional enclosed content, and assembles the bracketed string WordPress will actually parse. Attributes go in one per line as key = value or key: value, and a JSON object is accepted too. Blank lines and lines beginning with # are skipped, a pair of quotes you typed around a value yourself is stripped before the value is re-quoted properly, and a line with no separator becomes an attribute with an empty value rather than a bare flag.

The quoting is the part worth having. Double quotes are the default; Prefer single quotes uses them wherever the value allows, and Only quote when needed leaves simple values such as 3, medium or a bare URL unquoted — though a query string puts the quotes back, because ? and = are outside the small set of characters that are safe unquoted. Whatever you choose, a value containing a double quote is written in single quotes instead, because that is the only form the shortcode parser reads correctly. Two inputs are refused rather than mangled: a value holding both quote characters, which shortcodes have no escape syntax for, and a value containing a square bracket, which would end the shortcode early. Attribute names are checked as well — they must begin with a letter or underscore, and a name that appears twice is rejected, case differences included, since WordPress would keep only the last of them.

Everything is assembled in this browser tab, so the attributes you type, the enclosed content and any client details inside them are not uploaded anywhere. What the tool cannot do is make the shortcode exist: it writes the call, not the registration, and a tag that no plugin or theme has registered with add_shortcode is printed in the post exactly as typed. Tick Also write the PHP handler and you get that registration — an add_shortcode line, a shortcode_atts block using your attribute values as the defaults, and an output buffer — but treat it as a scaffold. The generated body prints each attribute through esc_html inside a div named after the tag, which is a starting point for your own markup rather than a finished feature.

How to use it

  1. Name the tag. Letters, digits, hyphens and underscores only — gallery, my-badge, contact_form. A tag with a space or a slash is refused, because WordPress would never match it.
  2. List the attributes. One per line as key = value or key: value, or paste a JSON object. Load sample fills the box with a gallery example that includes a caption containing quotation marks.
  3. Add enclosed content if the shortcode wraps something. Leave the box empty for the self-closing form. Put anything but whitespace in it and you get the enclosing form instead, with a matching closing tag written for you — spaces and newlines on their own still count as empty.
  4. Choose the quoting style. Always double quotes is the safe default. Prefer single quotes and Only quote when needed are there for house style, and either is overridden when a value forces the other.
  5. Take the shortcode, and the PHP if you need it. Copy the result straight into the editor, or tick the PHP options for a do_shortcode wrapper to drop into a template and a handler to paste into functions.php.

Processing & privacy

Runs on your device. Your file is processed directly in this browser.

Common use cases

Writing a gallery or form call by hand

Plugin documentation lists the attribute names but rarely the exact quoting, and a caption carrying an apostrophe is where hand-typed shortcodes usually break.

Calling a shortcode from a theme template

The editor is not the only place shortcodes run. The escape option wraps the call in do_shortcode with the surrounding PHP string quoting already worked out.

Starting a new shortcode on a client site

The handler output hands you a registered callback whose shortcode_atts defaults already match the attributes you listed, so the first version renders something real.

Documenting a shortcode for other people

Building each variation once, with consistent quoting, gives a handover document copy-paste examples instead of approximations someone has to correct later.

Questions

Does this register the shortcode for me?
Only if you ask for the handler. On its own the tool builds the call — the text that goes in a post — and a tag nothing has registered with add_shortcode appears on the page exactly as written. The handler checkbox produces the registration to paste into functions.php or a small plugin.
Why was my attribute value rejected?
Two kinds of value cannot be represented at all. One containing both a single and a double quote has no escape syntax inside a shortcode, and one containing a square bracket would terminate the shortcode early. Use a single kind of quote, an HTML entity such as ", or move the text into the enclosed content.
Are my attributes sent anywhere?
No. The whole thing is assembled by JavaScript in this tab, so the values, the content and anything identifying a client stay in your browser — which is why the page still works with the network disconnected.
What happens to true and false in a JSON object?
They become the strings true and false rather than empty values, because an empty attribute is falsy in PHP and would quietly switch the option off. WordPress passes every attribute to your callback as a string in any case, so the callback still has to interpret it, and the string false is itself truthy in PHP.
Can I nest a shortcode inside the enclosed content?
The builder inserts that content exactly as you typed it and does not inspect it, so nesting is your responsibility. WordPress expands an inner shortcode only when the outer callback runs do_shortcode over the content, and the generated handler passes it through wp_kses_post rather than doing that.
Is the generated PHP ready to ship?
It runs, but it is a skeleton. The body echoes each attribute through esc_html inside a div carrying the tag as its class, so replace that markup with whatever the shortcode should really output. The function name is built from the tag and the prefix field, which is what keeps it from colliding with someone else's.

Related tools