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
- Paste your JSON into the input box. It can be one line or many.
- Pick an indent style (2 spaces is conventional in JavaScript; 4 spaces in some other communities; tabs occasionally).
- 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 thisis invalid. - The literals
NaN,Infinity, andundefinedare 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 text | What'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 input | A bracket or brace was opened but never closed. |
| Unexpected string in JSON | Usually 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.
{name: "Ada"} is not valid JSON. Add quotes around every key.Can I include comments in JSON?
My file is 50 MB. Will it work?
jq.Does the tool preserve the order of object keys?
JSON.parse in all modern browsers preserves insertion order, and JSON.stringify serializes them in that order.Is my JSON sent anywhere?
JSON.parse. Nothing leaves your device.