Shortcode Builder
Build a shortcode call with its attributes quoted correctly — and, if you want it, the PHP behind it.
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
- 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.
- 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.
- 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.
- 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.
- 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?
Why was my attribute value rejected?
Are my attributes sent anywhere?
What happens to true and false in a JSON object?
Can I nest a shortcode inside the enclosed content?
Is the generated PHP ready to ship?
Related tools
- Meta Tag Preview — See how your title and description look in search results.
- Salt Key Generator — Produce a new set of WordPress authentication salts.
- wp-config Generator — Generate a wp-config.php with fresh security salts.
- .htaccess Generator — Build common Apache rules for WordPress.
- Serialized Data Fixer — Repair PHP serialized strings broken by search-replace.
- Theme Header Generator — Create a valid style.css theme header block.