Quick answer
A JSON formatter, or beautifier, re-indents JSON so its structure is easy to read without changing the data. Paste or drop JSON into Playxoft's free JSON Formatter and it is formatted as you type with 2 spaces, 4 spaces or tabs. Errors show their exact line and column with a fix, Repair turns JSONC or JavaScript-style objects into valid JSON, and Minify strips whitespace for the smallest payload.
- Format and minify
- 2, 4 or tab indent
- Line and column errors
- One-click repair
- Deep key sorting
- Collapsible tree view
- Exact big numbers
- Works offline
How to use the JSON Formatter
- 1Paste JSON into Input JSON, drop a
.jsonfile onto the editor, or click Open. - 2Choose Format and an Indent (2 or 4 spaces, or Tab), or choose Minify for a single line.
- 3Turn on Sort keys for a stable alphabetical key order at every level.
- 4If the status bar shows an error, click Go to error and fix it, or press Repair to fix common mistakes automatically.
- 5Copy or download the result, or switch the output to Tree to explore the structure.
What does a JSON formatter do?
JSON ignores whitespace between tokens, so {"a":1} and the same object spread over three lines are identical data. A formatter (also called a beautifier or pretty-printer) rewrites only that whitespace: one member per line and each level indented, so you can see the structure at a glance. Minifying does the opposite and removes every optional space and line break.
Formatting never changes the data. This tool prints from a lossless syntax tree rather than through JSON.parse and JSON.stringify, so:
- numbers keep their exact spelling:
1.50stays1.50, and12345678901234567890keeps all 20 digits; - string escapes such as
\u00e9stay exactly as you wrote them; - duplicate keys are kept and flagged, instead of silently collapsing to the last one;
- key order is preserved unless you turn on Sort keys.
The grammar it checks is RFC 8259, the current JSON standard, which matches ECMA-404 in substance.
Strict JSON vs JSONC vs JSON5: what's the difference?
Plenty of files that look like JSON aren't strict JSON. Three dialects cover almost everything you will paste:
| Feature | JSON (RFC 8259) | JSONC | JSON5 |
|---|---|---|---|
| Comments | No | Yes | Yes |
| Trailing commas | No | Parser-dependent (tsconfig accepts them) | Yes |
| Single-quoted strings | No | No | Yes |
| Unquoted keys | No | No | Yes |
| NaN, Infinity, hex numbers | No | No | Yes |
| Typical home | APIs, JSON.parse, databases | tsconfig.json, VS Code settings | Hand-edited config files |
Strict mode validates plain JSON: use it for anything a program will parse. Lenient mode accepts JSONC and keeps your comments when it re-indents.
To get strict JSON out of JSONC, JSON5 or a JavaScript object literal, click Repair. It strips comments and trailing commas, converts single quotes, quotes bare keys, replaces NaN, undefined and Python's True, False and None, unwraps Markdown code fences and JSONP callbacks, and lists every change it made. One click on Undo repair puts your original back.
What are the most common JSON errors and how do I fix them?
| Error | Looks like | Fix |
|---|---|---|
| Trailing comma | [1, 2, 3,] | Delete the comma after the last item |
| Single quotes | {'name': 'Ada'} | Use double quotes: {"name": "Ada"} |
| Unquoted key | {name: "Ada"} | Quote every key: {"name": "Ada"} |
| Comment | // production | Remove it, or use Lenient (JSONC) mode |
| NaN or Infinity | {"ratio": NaN} | Use null or a string |
| Leading zero | {"zip": 02134} | Store it as a string: "02134" |
| Missing comma | {"a": 1 "b": 2} | Put a comma between members |
| Line break inside a string | A string split over two lines | Escape the break as \n |
| Python literals | True, None | Use true and null |
The status bar under the editor names the first problem with its line and column, explains the fix, and Go to error puts the cursor right on it while the line is highlighted in the gutter. To see every error in a document at once, use the JSON Validator.
Why do big numbers change after JSON.parse?
JavaScript stores every number as a 64-bit float, which holds integers exactly only up to Number.MAX_SAFE_INTEGER: 2^53 − 1, or 9,007,199,254,740,991. Anything larger is rounded without warning:
JSON.parse('{"id": 9007199254740993}').id // 9007199254740992That is why large identifiers, such as snowflake IDs and some payment references, should travel as strings. Twitter's API famously sent every ID twice, as id and id_str, for exactly this reason.
This formatter never converts values to JavaScript numbers, so it keeps the digits you pasted and adds a warning for each unsafe integer, with its path. Other runtimes differ: Python's json module reads big integers exactly, and Go keeps them if you decode with json.Decoder.UseNumber().
How do I format JSON in code?
Every mainstream language has a built-in pretty-printer, and jq covers the shell:
// JavaScript / TypeScript
JSON.stringify(data, null, 2); // 2-space indent
JSON.stringify(data); // minified
# Python
json.dumps(data, indent=2, ensure_ascii=False, sort_keys=True)
python -m json.tool input.json # from the shell
# jq
jq . input.json # pretty-print
jq -S . input.json # sort keys
jq -c . input.json # minify
// Go
out, err := json.MarshalIndent(data, "", " ")Sorting keys (sort_keys=True, jq -S, or Sort keys here) gives a canonical order, which keeps diffs small and makes two documents easy to compare. To see exactly what changed between two versions, the JSON Diff tool compares them value by value, and the JSON to TypeScript generator turns a formatted response into types.
Frequently asked questions
Last updated by the Playxoft engineering team.