JSON Formatter — Beautify, Minify, Validate
Beautify, minify and validate JSON, sort keys, errors with line and column
Runs in your browser · nothing is uploaded
What it is
A JSON formatter turns one long line of JSON into readable, indented text, or strips all optional whitespace to make it smaller. Use it to inspect an API response, tidy a config file, or find the spot where the syntax broke. The result updates as you type, so there is no button to press.
How to use
- Paste your JSON into the input box.
- Choose 2 spaces, 4 spaces or tab indentation, or pick Minify.
- Turn on Sort keys if you want the keys ordered by character code. It reaches objects nested inside objects and inside arrays.
- Copy the result. If there is an error, the line and column are shown, so start fixing there.
How it works
- The grammar is JSON as in RFC 8259 (ECMA-404): double-quoted keys and strings only, no comments, no trailing commas.
- Error positions are 1-based lines and columns.
\n,\r\nand a lone\reach count as one line break. Columns count characters (code points), so an emoji takes one column, and the caret under the error line mirrors tabs. Numbers that overflow to Infinity (such as1e999) becomenullwith a warning, and nesting deeper than 512 levels is rejected with an explicit message. - Key sorting works at every level in code-unit order (uppercase before lowercase) and leaves array order alone. A key that appears twice in one object (
{"a":1,"a":2}) keeps only its last value under the JSON rules, so the result is still produced but a warning names the key and the line and column where it repeats. Because of how JavaScript objects work, integer-like keys such as"1"and"2"always come first in numeric order, whatever the option says. - Output keeps Korean, Chinese and emoji characters as they are and escapes only what JSON requires, such as
\nand\". A Unicode escape such as"\u0041"is written out as"A". - Numbers are read as JavaScript Numbers. Integers beyond 2^53 are not preserved exactly, and a warning tells you so.
Examples
| Input | Option | Result |
|---|---|---|
{"b":1,"a":{"d":2,"c":3}} |
Minify + sort keys | {"a":{"c":3,"d":2},"b":1} |
{"name":"홍길동"} |
2 spaces | multi-line, "name": "홍길동" |
{"a": 1,} |
— | line 1, column 9: unexpected character } |
{"id": 12345678901234567890} |
Minify | {"id":12345678901234567000} (warning shown) |
FAQ
Will I see where the JSON is broken?
Yes. The tool scans the input from the start and reports the line and column of the first character that breaks the rules, with that line and a caret under the spot. It computes the position itself instead of relying on browser error wording, so every browser gives the same answer.
Does it accept comments or trailing commas?
No. Only strict JSON as defined by RFC 8259 is accepted. Comments, trailing commas, single-quoted strings and unquoted keys are reported as errors with their location.
Can very large numbers change?
They can. The tool uses JavaScript's JSON parser, so integers beyond 9007199254740991 (2^53-1) are rounded to the nearest representable value. A warning appears when the input contains such a number. Wrap IDs of that size in strings if every digit matters.
Is my JSON sent to a server?
No. Everything runs in your browser and nothing is uploaded or stored.
Related tools
JSON to YAML Converter
Convert JSON to YAML (indent choice, key sorting, error positions)
JSON to CSV Converter
Convert a JSON array of objects to CSV (flattening, delimiters, Excel BOM)
JWT Decoder
Decode JWT header and payload and check expiry (no signature verification)
SQL Formatter
Beautify SQL (MySQL, PostgreSQL and other dialects, keyword case, indentation)