WordPress Gutenberg Markup Checker
Validate Gutenberg block comments, JSON attributes, and WordPress shortcodes after a post is translated. Catch invalid markup before it is imported back into the editor.
100% client-side: Your files never leave your browser.
Why WordPress Shows "This block contains unexpected or invalid content" After Translation
Gutenberg stores each block as an HTML comment plus a rendered wrapper. A heading comment carries JSON such as {"level":2}. WordPress parses every comment and checks that the wrapper still matches those attributes. If the JSON cannot be read, or the wrapper class no longer matches, the editor reports invalid content. Attempt Block Recovery then drops attributes it could not trust.
A translator or a language model often treats that short JSON as a sentence. Straight quotes become curly quotes, which JSON rejects. A comma disappears, or an entity such as " replaces a quotation mark. Posts sent through the WordPress REST API need the same check on content, since a successful save does not prove the block tree will open.
align, className, id, sizeSlug, and level are API names. Replacing align with a translated word leaves the div on a class such as alignwide while the comment no longer describes that class. A paired block that loses <!-- /wp:columns --> never finishes. A separator or synced pattern uses /--> and is already complete.
Shortcode tags and attribute names are registered in PHP. Translating gallery, or translating id, means the plugin does not recognize the tag after import. Text fields such as alt, caption, label, placeholder, title, and content may change. Keys, numbers, booleans, and technical strings may not.
Gutenberg Elements Reference Table
The comment is the source of truth. Inner HTML is the saved wrapper.
| Element | What it stores | What may change |
|---|---|---|
<!-- wp:name --> | Block type | Nothing in the name. Visible text may change. |
JSON attributes | Keys and values on the comment | Keys and numbers stay. alt, caption, and content may change. |
<!-- /wp:name --> | End of a paired block | The name and the nesting order stay. |
/--> | A finished void block | The slash stays. There is no separate closer. |
[shortcode] | Plugin tag and attribute names | Values may change. Tag and attribute names stay. |
Inner HTML | Wrapper tags, classes, and copy | Visible text may change. Classes such as alignwide must still match the comment. |
FAQ
Can a bulk WordPress REST API script validate Gutenberg markup before the draft is saved?
The posts endpoint stores content as a string. A successful write does not prove the block tree will open. Invalid JSON, a missing closer, or a translated shortcode still imports.
Why do translators break {"className":"..."} during a post translation?
className is a CSS hook, not a sentence. Rewriting every quoted string renames the key or the class, while the wrapper keeps the original class. Leave className, align, sizeSlug, slug, and type unchanged.
How should reusable and synced pattern blocks be handled?
A synced pattern is the self-closing comment <!-- wp:block {"ref":108} /-->. Translating the numeric ref points at the wrong pattern. Keep the ref and the trailing slash.
What is the difference between a paired block and a self-closing /--> block?
A paired block has an opener, a closer, and wrapper HTML between them. A self-closing block ends with a slash and has no closer. Only a paired block can be left unclosed.
Does this checker upload the WordPress post?
No. Parsing and the report run in the browser. Pasted HTML and dropped files stay on the machine, and nothing is sent to an API.
After the block comments are clean, static HTML can be translated on HTML Translate. Check merge tags with Email Tag Guard. See translating HTML without breaking layout and the tools hub.