JSON Formatter and Validator
Paste minified or badly indented JSON and get back a document you can actually read — with key order, number literals and duplicate members preserved exactly as they were written, and every syntax problem pinned to a line and column.
Indent
Key order
Input JSON
Formatted output
{
"users": [
{
"id": 9007199254740993,
"name": "Anneå",
"roles": [
"admin",
"ops"
],
"active": true,
"score": 4.5,
"note": null
},
{
"id": 2,
"name": "Li Wei",
"roles": [
"ops"
],
"active": false,
"score": 3.25,
"note": "queued for review, 2026-01-07"
}
],
"page": 1,
"total": 2,
"next": null
}Valid JSON
Warnings on this document
warningline 1, col 17 · byte 169007199254740993 exceeds 2^53−1 and cannot be held exactly by a double-precision float.
Values this large lose digits in JavaScript, JSON.parse, most browsers and many backends. Quote them or use a BigInt-aware parser. This formatter keeps the original text so nothing is lost here.
- Depth
- 5
- Objects
- 3
- Arrays
- 3
- Members
- 16
- Strings
- 6
- Numbers
- 6
- Booleans / null
- 2 / 2
- Duplicate names
- 0
- Minified bytes
- 252
- Pretty bytes
- 429
- Root
- object
- Lines
- 1
Longest nesting chain
Largest holds 2
None
177 of whitespace
1 records
A printer that re-indents without rewriting your data
Most online formatters parse with JSON.parse and print with JSON.stringify. That silently changes your data: a 17-digit identifier becomes a rounded double, a repeated key disappears, and the order you depended on in a diff is gone. This tool parses the text into an abstract syntax tree that keeps each member and each numeric literal as written, then prints that tree. The only thing that changes is whitespace.
Choose two spaces, four spaces, a tab, or a custom width, and the output is stable — run it twice and the second pass is byte-identical. That matters when a formatted file lands in version control, because an unstable printer produces churn in every review.
When the input is not valid JSON, the formatter does not guess. It reports the first error position, the token it expected, and — where a fix is unambiguous — offers a repair pass that converts JavaScript-style object keys, single quotes, trailing commas, comments and unquoted strings into conforming JSON and lists every change it made.
What the formatter does with your document
- Two, four, tab or custom indentation with byte-stable output
- Key order preserved exactly as written
- Numeric literals kept verbatim, so big integers survive
- Duplicate member names retained rather than collapsed
- Unicode kept as-is or escaped to \u sequences
- Optional key sorting ascending, descending or by first-seen
- Syntax errors pinned to line, column and byte offset
- Optional repair pass for JSON5-style input with a change log
- Drag-and-drop or pick a .json, .txt, .ndjson or .log file
- Download the result, copy it, or see size and node counts
How to format a JSON string
- 1Paste or drop the JSONType into the input pane, paste a response body, or drag a file onto it. A minified single-line payload is fine — the parser works on characters, not lines.
- 2Pick indentation and escapingTwo spaces is the convention for most JavaScript and API work; four is common in Python-adjacent configs; a tab suits documents reviewed in an editor with tab-width settings.
- 3Read the diagnostics before you trust the outputWarnings tell you what a normal parser would have hidden: duplicate keys, integers above 2^53-1, a leading byte-order mark, or a file of newline-separated records rather than one document.
- 4Copy or download the resultCopy to the clipboard or save as a .json file. The status bar reports characters, bytes, lines, depth and how many members were touched.
Formatting options and what each one changes
| Option | Default | Effect |
|---|---|---|
| Indent | 2 spaces | Width of one nesting level. Output is stable for any fixed value. |
| Key order | Keep as written | Sorting is opt-in; keeping order preserves diffs and semantic ordering in JSON Schema properties. |
| Number literals | Verbatim | Prints the exact characters from the input, so 9007199254740993 survives instead of becoming 9007199254740992. |
| Unicode | Kept raw | Switching to escapes turns € into \u20ac, which is the same string but readable in a legacy transport. |
| Repair mode | Off | Accepts single quotes, unquoted keys, comments, trailing commas and NaN, then logs each substitution. |
| Line ending | LF | CRLF for Windows editors that insist on it. |
Nothing in this table is configurable server-side; the options exist only in this tab and are not remembered between visits.
Frequently asked questions
Does this formatter keep duplicate keys?
Yes. RFC 8259 §4 says names in an object SHOULD be unique but does not forbid repeats, and JSON.parse keeps only the last value for a duplicated name. This tool works from the parsed syntax tree, so printing preserves both members and the warning tells you the collision is there.
Why does my long ID change when I format it elsewhere?
Because that tool converted the number to an IEEE-754 double. Doubles hold 53 bits of mantissa, so integers above 9007199254740991 (2^53 − 1) lose their low bits. Here the digits are printed exactly as typed; see the JSON validator for the warning.
Can it format NDJSON or a log file?
A file where each line is its own JSON document is not one valid document, so the formatter detects that shape, reports the record count and formats each line, then joins them back with newlines rather than inventing an array you did not ask for.
What is the largest file it can handle?
Roughly a few hundred megabytes of text on a typical laptop, limited by the tab heap rather than any hard cap in the code. Above that, use a streaming parser such as jq, Go json.Decoder or Python ijson.
Does it sort keys alphabetically?
Only if you ask. Sorting is offered ascending, descending and numerically for object-like keys, because a sorted diff of a stable document is often more readable — but key order can carry meaning, so keeping it is the default.
Is formatted JSON slower to send over the network?
Yes, and measurably so: indentation is pure overhead. Format for reading and use the JSON minifier for transport; gzip typically shrinks the difference to a few percent, which is why pretty-printing in development is acceptable and in production is not.
What does this do that a paste box does not?
It parses to a syntax tree that keeps the literal characters of every number, so a snowflake ID such as 9007199254740993 prints with all sixteen digits instead of being rounded by the double-precision conversion JSON.parse performs before anything is printed. On top of that it reports duplicate names, marks the line and column of every syntax problem, recognises NDJSON, and cites the RFC 8259 clause behind each diagnostic so the message can be checked against the standard rather than taken on faith.