JSON formatter

Format, validate and minify JSON instantly. Paste raw JSON and get it prettified with one click.

Indent:
Paste JSON and click Format
Input 0 bytes
Output
0 bytes
— keys · — values · — depth · — arrays
Send output to:

Ctrl + Enter format  |  Ctrl + Shift + M minify  |  Ctrl + L clear

The history of JSON

JSON — JavaScript Object Notation — was popularized in the early 2000s by Douglas Crockford, who insists he "discovered" rather than invented it, since the syntax already existed inside JavaScript's object literals. He specified it on a famously terse one-page site, json.org, as a lightweight alternative to the XML that dominated data exchange at the time. The bet paid off completely: JSON's minimal grammar — objects, arrays, strings, numbers, booleans and null — proved expressive enough for almost everything, and it displaced XML as the default format of web APIs. It was formally standardized as ECMA-404 in 2013, with the spec proudly noting the grammar fits on a single page.

Minifying JSON for production

Click Minify to remove all whitespace from your JSON and produce the most compact possible output. The stats bar shows the size reduction. Minified JSON transmits faster over networks, uses less bandwidth for APIs, and reduces payload size for applications. For large JSON objects the size reduction from removing whitespace can be significant — a 100KB prettified file might minify to 60KB. Always keep a prettified version for development and use minified JSON for production API responses.

Understanding the JSON stats

The stats bar below the panels shows four metrics about your JSON structure. Keys shows the total number of property names across all objects. Values shows the total number of values including strings, numbers, booleans, nulls, arrays, and objects. Depth shows how many levels of nesting your JSON has — deeply nested JSON (depth 6+) can be a sign of overly complex data structures. Arrays shows how many array elements are present across all arrays in the document.

Common JSON errors and fixes

Trailing commas are the most common error — JSON does not allow a comma after the last item in an array or object. JavaScript allows this but JSON does not. Single quotes are invalid in JSON — all strings including property names must use double quotes. Undefined and NaN are not valid JSON values — use null instead. Comments are not supported in JSON — remove any // or /* */ style comments before parsing. Property names must always be quoted strings — {name: "value"} is invalid, {"name": "value"} is correct.

Frequently asked questions

How do I format JSON online?

Paste your raw or minified JSON into the input panel and click Format / Prettify — the parsed result appears in the output panel with clean indentation and line breaks. Pick 2-space indentation (the most common convention), 4-space (preferred by several style guides) or tabs to match your project. Because parsing happens in your browser, even API responses containing sensitive data never leave your machine.

What is the difference between prettify and minify?

They are opposite transformations of the same data. Prettify adds indentation and line breaks so humans can read the structure — ideal for debugging and code review. Minify strips every non-essential character to make the payload as small as possible; a 100KB prettified file can shrink to roughly 60KB, which matters for API responses and bandwidth. The data is identical either way, so the standard workflow is prettify to work, minify to ship, with the stats bar showing the size difference.

Why is my JSON invalid?

Read the error message first — it reports the position of the first character the parser choked on, which is usually at or just after the actual mistake. Then check the usual suspects in order of likelihood: a trailing comma after the last item (legal in JavaScript, illegal in JSON), single quotes instead of double quotes, an unquoted property name, or an unescaped backslash in a string. Fixing the first error and re-validating often clears several downstream errors at once, since one broken character derails everything after it.

Can I validate JSON without formatting it?

Yes — validation runs automatically as you type, before you click anything. The status bar shows a green indicator when the JSON parses cleanly and a red one with the parser's exact error message and position when it does not. This makes the tool useful as a pure validity checker: paste a config file or API payload, read the verdict, and leave the formatting untouched if all you needed was confirmation.

Why doesn't JSON allow comments?

Deliberately. Douglas Crockford removed comments from the specification early on, explaining that people were abusing them to hold parsing directives — instructions that would have fractured the format's interoperability. The absence still surprises developers daily, since config files beg for annotation. Standard workarounds include adding a data field like "_comment", or using JSONC (JSON with comments), which tools like VS Code accept for their own config files — but strict parsers, and this validator, will correctly reject // and /* */ comments in plain JSON.