JSON Formatter
Paste your JSON below to format, validate, and beautify it instantly.
- Free
- No account
- Runs in your browser
- Nothing uploaded
Runs entirely in your browser — your input is never uploaded, logged, or stored.Privacy policy
What is JSON Formatter?
JSON (JavaScript Object Notation) is a lightweight text format for structured data, built from objects (key-value pairs), arrays, strings, numbers, booleans, and null. It's whitespace-insensitive, so minified JSON from an API response or log file is valid but hard to read — this tool re-indents it into a consistent, human-readable structure and checks along the way that it's actually valid JSON.
Two jobs, then: tell you whether the text parses at all, and if it does, show it in a shape you can read. When it doesn't parse, the useful part isn't the word "invalid" — it's where. The error is reported with a line and column so you can go straight to the character that broke it, rather than re-reading a 400-line payload looking for a missing brace.
It is also worth knowing what JSON leaves out, because that is where most surprises come from. There is no date type, so timestamps travel as strings and both ends have to agree on a format. There is one number type rather than separate integers and floats. And every key is a string, even one that looks like a number: {"2": "a"} has the key "2", not the integer 2, which is why the key ordering below can catch you out.
Formatting uses the browser's native JSON.parse followed by JSON.stringify with your chosen indent width — the same parser your code will use, so if this tool accepts it, your application will too.
That round trip is worth understanding, because it is a re-serialisation rather than a reformat of your original text, and three things can come out different from how they went in. Numbers larger than JavaScript can hold exactly lose precision: 12345678901234567890 comes back as 12345678901234567000. Duplicate keys collapse to the last one, so {"a":1,"a":2} becomes {"a":2}. And keys that look like integers are re-ordered ahead of the rest in ascending numeric order, because that is how JavaScript objects order their own properties — {"2":"a","1":"b","x":"c"} comes back as {"1":"b","2":"a","x":"c"}. None of these are bugs in the tool; they are what any JavaScript program that parses your JSON will also do. They are stated here because a formatter that quietly changes your data while claiming to only add whitespace is worse than one that explains itself.
| Strict JSON (this tool) | JSON5 / JSONC | |
|---|---|---|
| Comments | Rejected | Allowed |
| Trailing commas | Rejected | Allowed |
| Single-quoted strings | Rejected | Allowed |
| Unquoted keys | Rejected | Allowed |
| NaN and Infinity | Rejected | Allowed (JSON5) |
| Where you meet it | APIs, config payloads, log lines | tsconfig.json, VS Code settings |
Worked examples
- Input: {"name":"Ada","active":true,"tags":["math","cs"]}
- Output (2-space indent): { "name": "Ada", "active": true, "tags": [ "math", "cs" ] }
- Duplicate keys collapse to the last: {"a":1,"a":2} formats as {"a": 2}.
- Integer-like keys are re-ordered ahead of the rest: {"2":"a","1":"b","x":"c"} formats as {"1": "b", "2": "a", "x": "c"}.
- Precision beyond a double: {"n":12345678901234567890} formats as {"n": 12345678901234567000}.
How to use JSON Formatter
- Paste or type your JSON into the input box.
- Choose how it should come out: 2 spaces, 4 spaces, or Minified for a single compact line.
- Read the formatted, validated result — or the exact error location if it's invalid.
- Copy the output. Nothing is stored, so closing the tab is all the cleanup there is.
Common errors
- "Unexpected token , " — usually a trailing comma after the last item in an object or array; JSON, unlike JavaScript object literals, does not allow trailing commas.
- "Unexpected token ' " — JSON strings must use double quotes; single-quoted strings are valid JavaScript but invalid JSON.
- "Unexpected end of JSON input" — usually a missing closing brace `}` or bracket `]`; check that every opening symbol has a matching close.
- "Unexpected token u" on a value like `undefined` — JSON has no `undefined`; use `null` instead.
- "Unexpected token N" on `NaN`, or the same on `Infinity` — neither is valid JSON. There is no way to write them; the usual substitutes are `null` or a string.
- An error pointing at a line that looks correct — check the line *above* it. A missing comma is reported at the token that arrived unexpectedly, which is the start of the next line, not the end of the one that is actually missing the comma.
FAQ
Why does this tool say my JSON is invalid when it looks fine?
The most common causes are a trailing comma, single quotes instead of double quotes, or an unquoted object key — all valid in JavaScript object literals but not in strict JSON. The error message includes the exact line and column so you can jump straight to the problem.
Is my data uploaded anywhere when I use this formatter?
No — parsing and formatting both happen entirely in your browser using JavaScript's built-in JSON parser. Nothing you paste is sent to a server.
Can I minify JSON as well as beautify it?
Yes — choose "Minified" from the indent selector. That produces the same JSON on a single line with no spaces between tokens, which is what you want before putting a payload in an environment variable, a header, or a test fixture.
Does this validate against a JSON Schema, or just check that the JSON itself is well-formed?
Just well-formed JSON syntax — it confirms the text is parseable JSON, not that it matches a particular schema or shape your application expects. A payload can be perfectly valid JSON and still be missing every field your API requires.
Will formatting change my data, or only the whitespace?
Almost always only the whitespace, but not quite always, and the exceptions are worth knowing. The tool parses your text and re-serialises it, so anything JavaScript's own JSON parser normalises changes too: integers beyond about 9 quadrillion lose precision, duplicate keys collapse to the last one, keys that look like integers move to the front in ascending order, and -0 becomes 0. Every one of those also happens inside any program that parses your JSON — the tool is showing you what your data actually becomes, not damaging it.
Why did my large ID number change?
JavaScript numbers are IEEE-754 doubles, exact only up to 9,007,199,254,740,991. A 20-digit ID like 12345678901234567890 comes back as 12345678901234567000 — the digits past that limit were never representable. This is why APIs that use large integer IDs, such as Twitter's or Discord's, send them as strings. If you are debugging a mismatched ID, that is usually the cause.
Can it handle JSON with comments, like tsconfig.json?
No, and neither will your language's JSON parser. Comments are not part of the JSON standard — files like tsconfig.json and VS Code's settings are JSONC, a superset supported by those specific tools. Strip the comments first, or use a JSON5/JSONC parser.
How large a file can I paste in?
There is no limit imposed by the tool, because there is no upload — the work happens in your browser tab. The practical ceiling is your device's memory and patience: a few megabytes is comfortable, tens of megabytes will make the tab stutter while it renders the result.
Is the output valid JSON I can paste straight back into my code?
Yes. The output is produced by the same JSON.stringify that your own JavaScript would call, so it is valid JSON by construction — including correct escaping of quotes, backslashes, newlines and non-ASCII characters inside strings.
Related tools
- UUID GeneratorClick below to generate a random, version-4 UUID you can use immediately.
- CSS Gradient GeneratorBuild CSS gradients visually — pick a type, choose colors, adjust the angle, and copy clean CSS.
- YAML to JSON ConverterPaste YAML below to convert it to JSON, with every value the conversion silently changed listed underneath it.
Prefer AllUtil on Google
One click adds AllUtil to your Google preferences. You'll see our tools highlighted with a Preferred badge in Search and AI answers.