JSON Formatter & Validator
Paste JSON to pretty-print it, find syntax errors by line and column, or minify it. Everything runs in your browser.
Result
How to use the JSON formatter
Paste JSON into the box on the left, or press Load example to try it with sample data.
With Format as I type on, the result updates as you edit. Choose 2 spaces, 4 spaces or tabs
for indentation, tick Sort keys to order object keys alphabetically at every level, and use
Minify when you need the smallest possible output. Copy the result or download it as a
.json file.
The formatter runs entirely in your browser. Nothing you paste is sent to a server, so it is safe to use with API responses, config files and logs that contain private data.
Reading validation errors
When the input is not valid JSON, the validator shows the line and column where parsing stopped, an excerpt of that line with a marker under the problem, and a plain-language hint when it recognises the mistake. The position points to where the parser gave up, which is usually at or just after the real error. If the hint doesn't match what you see, look at the character right before the marker.
Common JSON syntax errors
Most invalid JSON comes from writing it the way you would write a JavaScript object. The usual causes:
| Mistake | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1,} | {"a": 1} |
| Single quotes | {'a': 'b'} | {"a": "b"} |
| Unquoted keys | {a: 1} | {"a": 1} |
| Comments | {"a": 1 // note} | {"a": 1} |
| Special numbers | {"a": NaN} | {"a": null} |
| Leading zeros or plus sign | {"a": 007} | {"a": 7} |
| Unescaped line break in a string | "line one⏎line two" | "line one\nline two" |
| Invalid escape | "C:\path" | "C:\\path" |
Also check for a missing comma between two values, a bracket that is never closed, and text that was cut off when you copied it from a terminal or log viewer. If the error says the input ends early, the JSON was probably truncated.
What counts as valid JSON
JSON is defined by RFC 8259 and ECMA-404. A JSON document is a single value: an object, an array, a string,
a number, true, false or null. Strings and object keys must use double
quotes. Numbers are written in decimal, with an optional fraction and exponent; hex, octal,
Infinity and NaN are not allowed. Whitespace between tokens is ignored, which is why
formatting never changes what the data means.
Formats such as JSON5, JSONC (used by some editor config files) and JSON Lines look similar but are not JSON. JSON5 and JSONC allow comments and trailing commas; JSON Lines puts one JSON value on each line. To validate a JSON Lines file here, check one line at a time.
Beautify or minify?
Beautified JSON is for people: it makes nesting visible and diffs readable, so use it for config files, docs and code review. Minified JSON removes every optional space and newline, which makes payloads smaller for APIs, storage and embedding in URLs or HTML. If your server compresses responses with gzip or Brotli, the size gain from minifying is smaller than it first looks, but it still helps.
Sorting keys is useful when you compare two JSON documents. Two objects with the same data in a different key order look different in a diff; sort both first and only the real changes remain. Sorting never changes array order, because array order carries meaning.
Things to know about the output
The formatter parses your input and writes it back out, so the output is normalised. Escapes such as
\u00e9 are shown as the character they represent, and number spellings such as
1.0 or 1e3 are written in their shortest form (1,
1000). If an object has the same key twice, only the last value is kept, which matches how most
JSON parsers behave.
Integers larger than 253 − 1 (9,007,199,254,740,991) lose precision in JavaScript, and the browser uses JavaScript to parse. If your data contains large IDs, such as some database keys or social media post IDs, the last digits may change in the output. APIs usually avoid this by sending large IDs as strings.
Working with search API responses
SERP APIs return large nested JSON documents. Format a response here to find the fields you need, or paste it into the SERP Parser to turn the organic results into a table you can export as CSV. To make a live request and see the raw response, use the Search API Tester.
Frequently asked questions
Is my JSON uploaded anywhere?
No. Formatting and validation run in your browser with JavaScript, and nothing you paste is sent to a server. If your input is under 200 KB, it is kept in your browser's local storage so it is still there when you come back.
Why does my JSON fail to validate?
The most common causes are a trailing comma, single quotes instead of double quotes, keys without quotes, and comments. The validator shows the line and column where parsing stopped and, when it recognises the mistake, a hint on how to fix it.
What is the difference between beautify and minify?
Beautify adds line breaks and indentation so people can read the structure. Minify removes all optional whitespace to make the payload as small as possible. Both keep the data exactly the same.
Does JSON allow comments or trailing commas?
No. Standard JSON (RFC 8259) allows neither. Formats such as JSON5 and JSONC accept them, but a standard JSON parser will reject the file.
Why did a large number change after formatting?
Browsers parse JSON numbers as JavaScript numbers, which are exact only up to 9,007,199,254,740,991. Larger integers lose their last digits, which is why many APIs send big IDs as strings.