Developers · Gutenberg
JSON Formatter block for WordPress
Validate, format (pretty-print), and minify JSON with syntax highlighting and one-click copy.
Get Blockenberg
Free Gutenberg block in Blockenberg. The inspector controls and front-end behavior on this page come from this block’s source, not a shared stub.
What it actually does
Validate, format (pretty-print), and minify JSON with syntax highlighting and one-click copy.
Inspector panels on this block: Content, Display, Sizing. Those titles come from index.js, not from a shared template.
Behavior controls: “Indent size” options: 2 spaces, 4 spaces, 1 tab.
Where to find it
Gutenberg inserter → Developers → search “JSON Formatter” (block name `blockenberg/json-formatter` in block.json). Style it in the sidebar after insert.
How to use JSON Formatter block for WordPress
- Install Blockenberg. Install from WordPress.org and activate the plugin.
- Insert the block. Edit a page, click +, search for “JSON Formatter”, insert it. Category: Developers.
- Configure inspector controls that exist on this block. Open Content. Set “Content — Title”, “Subtitle”, “Indent size”, “Size (px)”.
- Check the published page. The view script reads HTML data attributes: data-opts. The block editor preview may not run the same view script.
Inspector controls from this block’s code
| Control | What the code does |
|---|---|
| Content — Title | Text field in the inspector. block.json default: JSON Formatter & Validator. Saved as `title`. |
| Subtitle | Text field in the inspector. block.json default: Paste JSON to validate, format, or minify it instantly.. Saved as `subtitle`. |
| Indent size | Select control; the chosen value is saved on the block. Options: 2 spaces; 4 spaces; 1 tab. block.json default: 2. Saved as `indentSize`. |
| Size (px) | Numeric range control in the inspector. Range 8–72. block.json default: 13. Saved as `outputFontSize`. |
| Weight | Numeric range control in the inspector. Range 100–900. block.json default: 400. Saved as `outputFontWeight`. |
| Line Height | Numeric range control in the inspector. Range 0.8–3. block.json default: 1.6. Saved as `outputLineHeight`. |
What the front-end script actually does
- The view script reads HTML data attributes: data-opts.
- Keyboard handlers move focus between items.
When this is the right block
- Validate, format (pretty-print), and minify JSON with syntax highlighting and one-click copy — that is the job of JSON Formatter, not a generic content block.
- Use it when you need the editor control labeled “Content — Title”, which exists on this block’s inspector.
- It matches pages about json, formatter, validator.
- Inserter grouping: docs sites, utilities, and developer landing pages.
Notes from the implementation
viewScript: this folder’s frontend.js is enqueued on the front end for this block.
FAQ
How do I add the JSON Formatter block in WordPress?
Install Blockenberg from WordPress.org, edit a page in the block editor, click +, and search for “JSON Formatter”. It sits under Developers. After insert, open Content and set “Content — Title”, “Subtitle”, “Indent size”, “Size (px)”.
Does JSON Formatter generate a PDF on the server?
No. It opens the browser print dialog. Visitors can choose Save as PDF there.
Is the JSON Formatter Gutenberg block free?
Yes. JSON Formatter ships inside Blockenberg. Get the plugin from WordPress.org — no paid add-on is required for this block.
Can I style JSON Formatter to match my theme?
Yes. Blockenberg’s shared typography and color panels apply here, plus any block-specific style controls listed on this page (panels: Content, Display, Sizing).
Related developers blocks
API Reference
Display API endpoint documentation with method badge, parameters table, and request/response code examples.
Code Tabs
Multi-language tabbed code viewer with syntax highlighting. Show the same snippet in JavaScript, Python, PHP, and more.
Base64 Encoder / Decoder
Encode plain text to Base64 or decode Base64 back to text. Supports Unicode, URL-safe Base64 and one-click copy.
Clipboard Copy
Display a copyable code, coupon, or text with a one-click copy button.
Code Block
Syntax-highlighted code block with copy button, line numbers, and multiple themes.
Code Comparison
Side-by-side code comparison block with syntax highlighting, diff markers, labeled panels, copy buttons, line numbers, and a draggable split divider.
Get Blockenberg
Install Blockenberg from WordPress.org, then insert JSON Formatter from the Gutenberg inserter.