JSON Formatter
Pretty-print, minify and explore JSON in a tree view — with the exact line and column of any syntax error.
- Runs in your browser — files never leave your device
- Instant — no waiting, no queue
Open .json file
Drop a file, click to browse, or paste with Ctrl/Cmd+V
Syntax error: Enter some JSON to format.
Formatted JSON will appear here.How to use
- Paste or type JSON into the box, or drop a .json file onto it.
- Read live size, depth and key stats, and switch the right panel between Formatted, Minified and Tree.
- Pick 2-space, 4-space or tab indent for the formatted view.
- Turn on “Sort keys A–Z” for an alphabetically sorted, diff-friendly copy.
- If the JSON is invalid, read the plain-language error and click “Jump to error” to select the exact character.
- Copy or download the result — your JSON never leaves this tab.
Why error messages differ from your browser console
Browser JSON error messages vary. This tool checks a failed document against the JSON grammar from RFC 8259 and reports the first problem as a line, column and plain-language reason, then “Jump to error” selects that character in the input.
Strict JSON requires double quotes around property names and strings. It does not allow a comma before a closing bracket, a leading zero in a number (01), or a bare decimal point (1. or .5).
Common reasons JSON fails to parse
Trailing comma: {"a": 1, "b": 2,} — remove the comma before }. Single quotes: {'a': 1} — JSON requires double quotes for both keys and string values. Unquoted keys: {a: 1} — wrap the key in quotes. Comments: JSON has no // or /* */ syntax at all; if your data has comments it is JSON5 or JSONC, not plain JSON, and needs a different parser. Values that only exist in JavaScript — a missing property, an infinite number, or "not a number" — are also not valid JSON; use null or a string instead.
Formatted, minified or tree — which to use
Formatted (pretty-printed) JSON is easiest to read and review in a pull request. Minified JSON strips whitespace outside strings, which is useful for compact API requests or one-line configuration fields. Tree view is best for exploring a nested API response: collapse branches you do not need, and use “Show more” to reveal large arrays and objects in batches of 50 items.
Nothing is uploaded
Parsing, sorting, formatting and the tree view run in this browser tab. No file or text is sent to a server. The practical limit depends on your device’s memory and browser; very large documents can still take time to parse or format. The tree initially shows 50 children at a time and leaves deeper branches collapsed to keep exploration responsive.
Frequently asked questions
Why do I get a trailing comma error?
Standard JSON (RFC 8259) does not allow a comma right before a closing "}" or "]". {"a": 1, "b": 2,} is invalid; remove the last comma so it reads {"a": 1, "b": 2}. Some languages (like JavaScript object literals) allow trailing commas, which is a common source of confusion.
Is it safe to paste an API response that contains a token or personal data?
Yes. This tool runs entirely in your browser using JavaScript’s built-in JSON engine — nothing you paste, drop or type is ever sent to a server. You can verify this yourself in your browser’s network tab: no requests fire while you use the tool.
What is the difference between JSON and JSON5 or JSONC?
Plain JSON (RFC 8259) has no comments, no trailing commas, and requires double-quoted keys. JSON5 and JSONC (used by some config files, like VS Code’s settings.json) relax those rules to allow comments, trailing commas and unquoted keys. This tool validates strict JSON; a JSON5/JSONC file will need its comments removed first.
Can I sort JSON object keys alphabetically?
Yes — turn on “Sort keys A–Z”. It recursively sorts every object’s keys (ordinal, A–Z) while leaving array order untouched, which is useful for producing a stable, diff-friendly copy of two JSON files that only differ in key order.
How large a JSON file can this handle?
There is no fixed application limit. The practical size depends on available device memory and the browser, and very large documents can still take time to parse or format. Tree view initially shows 50 children at a time and keeps deeper branches collapsed; use “Show more” only where you need to inspect more data.
Does JSON support comments?
No. The JSON specification (RFC 8259 / ECMA-404) has no comment syntax. If you need comments, you are likely working with JSON5 or JSONC (a superset used by tools like VS Code and TypeScript’s tsconfig.json), which require a different, more permissive parser.
Related tools
Updated 2026-10-15