JSON Formatter & Validator
Format, validate, and minify JSON — with clear error messages for invalid input.
Did this tool work for you?
How to use this calculator
- 1
Paste your JSON into the text area; surrounding whitespace is ignored.
- 2
Choose an action: format with 2 spaces, format with 4 spaces, minify, or validate only.
- 3
If the JSON is invalid, read the error message and position, then check one token before that spot.
- 4
Copy the Result, and compare the Input size and Output size rows if you are minifying.
Frequently asked questions
Which standard does the validator follow?
It uses the browser’s own JSON.parse, which implements the grammar in ECMA-404 and RFC 8259. A bare value such as null, 42 or "text" is accepted as a complete document, as that standard allows. The wording of the error message comes from the browser, so Chrome, Firefox and Safari describe the same mistake differently.
Why was my input rejected?
Typical causes are a trailing comma, single quotes instead of double quotes, unquoted keys, comments, and the values NaN, Infinity or undefined, none of which JSON permits. For {"a":1,} Chrome reports an expected double-quoted property name at line 1, column 8. Formats such as JSON5 and JSONC are not accepted.
Does formatting change my data?
It can, because the tool parses and rewrites rather than reflowing the text. Numbers are read as 64-bit floats, so 12345678901234567890 comes back as 12345678901234567000, and 1.50 becomes 1.5. A number too large for a float, such as 1e999, is output as null. Keep an unmodified copy of data that relies on large IDs.
Why did my keys change order?
JavaScript puts keys that look like whole numbers first, in ascending order, before the other keys. {"b":1,"a":[...],"2":"x","1":"y"} is returned with "1" and "2" at the top. Other keys keep their original order, so objects with ordinary names are not reordered.
What happens to duplicate keys?
The last one wins and the others disappear silently. {"a":1,"a":2} formats to {"a":2}, with no warning. RFC 8259 says names should be unique and that behaviour with duplicates is unpredictable, so fix them in the source rather than relying on this.
What does Validate only report?
The top-level type (Object, Array, String, Number, Boolean or null), the total number of keys counted through all nested objects, and the character count. Array items do not count as keys. {"user":{"name":"Ann","tags":["x","y"]},"ok":true} reports an object with 4 keys.
Is minified JSON always smaller?
Only if the input contained removable whitespace. Already-compact JSON stays the same size, and minifying never shortens the data itself. Output also normalises string escapes: \u00e9 returns as é, and an escaped slash returns as a plain slash.
Is my JSON uploaded?
No. Parsing and stringifying run in your browser and the tool’s code makes no network request, so pasting an API response with private data does not send it to a server. Treat the text as you would any clipboard content on a shared machine.
JSON formatting, minifying and validation
What the three actions do
Format re-indents with 2 or 4 spaces, minify removes every optional space and line break, and validate parses without printing the document. All three first trim the input and parse it, so a single syntax error stops everything and returns the parser’s message. The output is regenerated from the parsed data, not copied from your input, and that explains most surprises people see. An empty box returns a prompt rather than an error. Indentation applies at every nesting level, empty arrays and objects print as [] and {}, and the order of array items is always preserved.
What a round-trip can change
Anything the parser cannot represent exactly is altered when the document is printed again. Each case in the table was produced by the tool. Numbers go through a 64-bit float, so writing 1.0 or 1.50 keeps the value but not the spelling, and negative zero prints as 0.
| Input | Output | Why |
|---|---|---|
| 12345678901234567890 | 12345678901234567000 | Integers beyond 2^53 lose precision |
| {"p":1.0,"q":1.50,"r":1E2,"s":-0} | p 1, q 1.5, r 100, s 0 | Numbers are re-printed from the float value |
| 1e999 | null | Overflows to Infinity, which JSON cannot print |
| {"a":1,"a":2} | {"a":2} | Last duplicate key wins |
| {"b":1,"2":"x","1":"y"} | "1" and "2" first, then "b" | Integer-like keys sort first |
Error messages you may see
The text of an error comes from the JavaScript engine, not from this tool, and it was captured here from the V8 engine used by Chrome and Node. Firefox and Safari word the same mistakes differently and may leave out the line and column. The position counts characters from zero and usually points just past the real mistake, so look one token back.
| Input | Message (V8) |
|---|---|
| [1,2,3 | Expected ',' or ']' after array element … at position 6 (line 1 column 7) |
| {"a":1,} | Expected double-quoted property name … at position 7 (line 1 column 8) |
| {'a':1} | Expected property name or '}' … at position 1 (line 1 column 2) |
| {"a":1} {"b":2} | Unexpected non-whitespace character after JSON at position 8 (line 1 column 9) |
| 01 | Unexpected number … at position 1 (line 1 column 2) |
Worked examples
Formatting {"a":1} with 4 spaces gives a three-line object whose key is indented four spaces, growing the text from 7 to 14 characters; with 2 spaces it is 12. Minifying a two-record array that had been spread over several lines took it from 53 to 46 characters. Validating {"user":{"name":"Ann","tags":["x","y"]},"ok":true} returns Valid JSON, type Object, 4 keys, 50 characters. A key named __proto__ is kept as an ordinary key.
What it does not do
It accepts strict JSON only. Comments, trailing commas, single-quoted strings, unquoted keys and the values NaN, Infinity and undefined are all rejected, which rules out JSON5 and the commented JSONC used in some config files. It does not repair broken input, sort keys, check a schema, report duplicate keys or keep big numbers intact. It also stops at one document: two objects pasted back to back are an error. For anything where exact numbers matter, such as 64-bit IDs, compare the output with the original text.
Learn more from an authoritative source:
MDN Web DocsBase64 Encoder / Decoder
Encode plain text to Base64 or decode Base64 strings back to readable text.
URL Encoder / Decoder
Encode special characters in URLs (percent-encoding) or decode percent-encoded URLs.
UUID Generator
Generate UUID v4 (random) identifiers — one or in bulk.
Unix Timestamp Converter
Convert Unix timestamps to human-readable dates and times, and vice versa.
JWT Decoder
Decode and inspect JWT (JSON Web Token) headers and payloads without verifying the signature.
Cron Expression Generator
Generate and explain cron expressions — pick a preset or write your own.
Results are estimates for informational purposes only and do not constitute professional financial, medical, legal, or technical advice. Read full disclaimer →