About the JSON Formatter
This tool validates JSON against the standard grammar (RFC 8259) and reformats it. Format mode pretty-prints with 2 spaces, 4 spaces or tabs; Minify mode strips all insignificant whitespace. You can also sort keys alphabetically at every level to make payloads easier to compare. The output is syntax-highlighted with line numbers, and the status bar shows the size before and after, the line count, and how many keys, values and nesting levels the document has.
Parsing happens in your browser with the built-in JSON.parse, so you can paste API responses that contain tokens or customer data without sending them anywhere.
How to use it
- Paste JSON into the input pane, or click Load sample.
- Pick Format or Minify, an indent size, and whether to sort keys.
- If the input is invalid, read the error, which points to the line and column where parsing stopped.
- Copy the output or download it as
formatted.json.
Examples
- Format a minified API response: the one-liner is expanded into indented, highlighted lines.
- Find a trailing comma: the error reports line 1, column 15, right after the extra comma.
Common questions
Why is my JSON invalid?
The usual causes are trailing commas, single-quoted strings, unquoted keys, comments, and values like NaN or undefined. All of these are accepted by JavaScript but not by the JSON standard.
What happens to duplicate keys?
RFC 8259 says names should be unique but doesn't forbid duplicates. JSON.parse keeps the last value, so the formatted output contains only one copy of the key.
Why did a large number change?
Numbers are parsed as 64-bit floats, so integers above 2^53 (such as some database IDs) lose precision when reformatted. Send such IDs as strings if they must survive round trips.
Related tools
- CSV to JSON Converter: turn an array of objects into a spreadsheet-friendly CSV.
- Text Diff Checker: compare two formatted, key-sorted documents line by line.
- JWT Decoder: read the JSON inside a token's header and payload.