HTML to GenerateBlocks Converter V2
Convert any HTML to GenerateBlocks V2 format (element, text, media blocks) with styles and attributes
How to Use This Tool
Quick Start
- Paste your HTML code in the Input HTML panel
- Click Convert to GenerateBlocks
- Copy the output
- In WordPress Block Editor, switch to Code Editor (⋮ menu → Code Editor)
- Paste and switch back to Visual Editor
GenerateBlocks V2 Block Mapping
| HTML Element | GB V2 Block | Notes |
|---|---|---|
<div>, <section>, <header>, <footer>, <nav>, <article>, <aside>, <main> |
generateblocks/element |
Container with tagName preserved |
<h1> - <h6>, <p>, <span> |
generateblocks/text |
Text with tagName |
<a> |
generateblocks/text |
Link with tagName="a" and htmlAttributes.href |
<img> |
generateblocks/media |
Image with htmlAttributes.src/alt |
<button> |
generateblocks/text |
Button styled text with tagName="button" |
V2 Attribute Structure
- styles: Object with CSS properties (camelCase)
- css: Generated CSS string for the block
- className: Custom CSS classes (space-separated string)
- globalClasses: Array for GenerateBlocks global classes (predefined)
- htmlAttributes: Object for href, src, alt, data-* etc.
- tagName: The HTML element type
Example V2 Output
<!-- wp:generateblocks/element {"uniqueId":"abc123","tagName":"div","styles":{"padding":"20px","backgroundColor":"#f5f5f5"},"css":".gb-element-abc123{padding:20px;background-color:#f5f5f5}","className":"my-class"} -->
<div class="my-class gb-element-abc123">
<!-- wp:generateblocks/text {"uniqueId":"def456","tagName":"h1"} -->
<h1 class="gb-text">Hello World</h1>
<!-- /wp:generateblocks/text -->
</div>
<!-- /wp:generateblocks/element -->
Tips
- Classes from HTML are converted to
classNameattribute - Inline styles become
stylesobject +cssstring - The
gb-element-{uniqueId}class is only added when there are styles - Images use
generateblocks/mediawith htmlAttributes for src/alt