stoolme
Home/ Developer/ JSON formatter

JSON formatter

Paste JSON to pretty-print, minify, or validate it. Errors are reported with line and column numbers. Everything runs locally — your data never leaves the browser.

What this tool does

The JSON formatter takes a chunk of JSON and either re-indents it for readability (pretty-print), strips all whitespace for shipping (minify), or just checks whether the syntax is valid. Errors come with a precise line and column number, which most browser dev-tools won't give you for an ad-hoc JSON.parse() call.

How to use it

  1. Paste your JSON into the input box. It can be one line or many.
  2. Pick an indent style (2 spaces is conventional in JavaScript; 4 spaces in some other communities; tabs occasionally).
  3. Click Pretty-print, Minify, or Validate only.

If your JSON is invalid, the status line will tell you what went wrong and where. Common errors include missing commas, trailing commas (not legal in standard JSON), unquoted keys, and single-quoted strings (also not legal — JSON requires double quotes).

What strict JSON allows

Standard JSON, defined in RFC 8259, is more restrictive than the JavaScript-object literals it looks like. In particular:

  • Object keys must be double-quoted strings. {name: "Ada"} is invalid; {"name": "Ada"} is valid.
  • Strings must use double quotes, not single quotes.
  • No trailing commas. [1, 2, 3,] is invalid.
  • No comments. // like this is invalid.
  • The literals NaN, Infinity, and undefined are not allowed.

Many editors and APIs are lenient about these rules — JavaScript's own JSON.parse isn't. If a string looks like JSON but won't parse, the cause is usually one of the items above.

Common error messages, decoded

Error textWhat's wrong
Unexpected token …The parser found a character it didn't expect. Look at the column in the error for the offending character.
Unexpected end of JSON inputA bracket or brace was opened but never closed.
Unexpected string in JSONUsually a missing comma between two values.
Expected property name or '}'An object key was unquoted, or you have a trailing comma before }.

Pretty-print vs minify

Use pretty-print when you're reading JSON by eye, committing it to source control, or sharing it with a teammate. Use minify when you need the smallest possible bytes for an HTTP response, an embedded config, or a cache key. The two are functionally identical to consumers — the only difference is whitespace.

Privacy

JSON parsing and re-serialization happens entirely in your browser via native JSON.parse and JSON.stringify. The data you paste is never transmitted.

Frequently asked questions

Why doesn't my JSON parse — the keys aren't quoted.
Standard JSON requires double-quoted keys. A JavaScript object literal like {name: "Ada"} is not valid JSON. Add quotes around every key.
Can I include comments in JSON?
No — comments are not allowed in standard JSON. If you need comments, look at JSON5 or JSONC, both of which are supersets. This tool only accepts strict JSON.
My file is 50 MB. Will it work?
It will work, but slowly. The browser has to render the textarea, which is the bottleneck — not the parsing. For very large files, consider a command-line tool like jq.
Does the tool preserve the order of object keys?
Yes. JSON.parse in all modern browsers preserves insertion order, and JSON.stringify serializes them in that order.
Is my JSON sent anywhere?
No. The parser is the browser's own JSON.parse. Nothing leaves your device.