How to format JSON
- Paste your JSON into the box.
- Choose Pretty print to indent it, or Minify to remove all spacing.
- Press Run tool. If the JSON is valid, you get the formatted result. If not, you get an error message.
Pretty print uses two-space indentation, which is the most common style in JavaScript projects and WordPress block files. Minify puts everything on one line with no extra spaces.
Validation: what counts as valid JSON
The tool uses your browser's standard JSON parser, which follows the JSON specification strictly. These are the most common mistakes:
- Trailing commas.
{"a": 1,}is invalid. JavaScript allows it, JSON does not. - Single quotes. Strings and keys must use double quotes.
- Comments. JSON has no comments. Files like
tsconfig.jsonallow them only because their tools are lenient. - Unquoted keys.
{name: "x"}is a JavaScript object, not JSON. - Special values.
undefined,NaNandInfinityare not allowed.
When parsing fails, the error message usually includes a position or line number. Go to that spot and look just before it. The real mistake is often one character earlier, such as a missing comma at the end of the previous line.
Where WordPress users run into JSON
You do not need to be a developer to deal with JSON. It turns up all over a WordPress site:
- theme.json in block themes, which controls colours, fonts and spacing.
- block.json files in custom blocks.
- REST API responses, for example from
/wp-json/wp/v2/posts. - Plugin exports, such as settings from SEO, form or page builder plugins.
- Structured data in JSON-LD format. The schema markup generator creates it, and this tool checks it once you have edited it by hand.
A single misplaced comma in theme.json can make WordPress quietly ignore the whole file. Validating it here first is quicker than wondering why your colours did not change.
Pretty print or minify?
Use pretty print when a person needs to read, review or edit the data. Use minify when the data is going into a config field, an API request or an HTML attribute where size or a single line matters. Minifying usually saves 10 to 30 percent of the size, depending on how deeply the data is nested. For files served to browsers, gzip or Brotli compression on the server saves far more, so do not minify a file just for speed if your host already compresses it.
Limits to know about
- Very large numbers. Whole numbers bigger than 9,007,199,254,740,991 lose precision in JavaScript. Long IDs from some APIs can change silently. If you work with such IDs, keep them as strings.
- Duplicate keys. If an object has the same key twice, only the last value is kept in the output.
- Key order is preserved as written, except that keys made only of digits may be moved to the front. That is how JavaScript objects work.
Frequently asked questions
Is my JSON sent anywhere?
No. Parsing and formatting happen in your browser. That makes the tool safe for API responses that contain tokens or customer data, although you should still be careful where you paste secrets.
Can it fix invalid JSON automatically?
No. Automatic repair can guess wrong and change your data. The tool points to the problem so you can fix it yourself.