JSON Formatter
Format, beautify and validate JSON with 2 or 4 space indentation.
Updated · Examples checked by automated tests
0 B · 0 lines
Formatted JSON
Paste valid JSON on the left to see it formatted here.
About JSON Formatter
JSON (JavaScript Object Notation) is the default data-interchange format of the modern web. Minified JSON is efficient to transmit but painful to read, and a single misplaced comma is enough to break a parser without telling you where.
This formatter re-indents your document with two or four spaces, minifies it back down when you need to ship it, and reports the exact position of any syntax error so you can fix it immediately.
How JSON Formatter works in your browser
The browser validates JSON syntax, then a token formatter changes whitespace without rewriting values. Large integers such as 9007199254740993, exponent notation, negative zero and duplicate members remain intact. Downstream parsers may still round numbers or discard duplicate members; formatting does not change their behavior.
That choice has a visible consequence: the parser follows RFC 8259 strictly, so trailing commas, single-quoted strings, comments and unquoted keys are all rejected rather than quietly repaired. When parsing fails, the browser reports the character offset of the first token it could not accept, which is mapped back to a line and column and shown against your input.
Member order is preserved, including numeric-looking keys. Optional sorting orders decoded key names recursively. Statistics describe the parsed object, so duplicate members count only once; the output retains them.
When to use it
- Reading a minified API response you have just pulled out of a browser’s network tab.
- Finding the exact position of a syntax error in a config file that a build tool has only told you is "invalid".
- Normalising indentation across a set of fixture files so that code review shows real changes instead of whitespace.
- Inspecting synthetic or redacted payloads while reviewing local processing in browser developer tools.
Worked examples
Pretty-print a minified API response
Settings: 2 spaces
Input
{"name":"Ada","langs":["en","fr"],"active":true}Expected output
{
"name": "Ada",
"langs": [
"en",
"fr"
],
"active": true
}Only whitespace changes. Keys stay in their original order and values are copied exactly as written.
Sort keys without rounding a large number
Settings: 2 spaces, Sort keys on
Input
{"b":1,"a":9007199254740993}Expected output
{
"a": 9007199254740993,
"b": 1
}9007199254740993 is larger than JavaScript can represent exactly; a formatter that parsed and re-serialised it would print 9007199254740992. This one copies the original digits.
Limits and checks before you use the result
- Input must be strict JSON. Comments, trailing commas and single quotes are rejected rather than repaired.
- Sorting orders keys alphabetically at every level, which changes the document order. Leave it off when order matters to a reader.
- Very large documents are limited by your device’s memory and can render slowly on phones.
Frequently asked questions
Is my JSON uploaded for processing?
Our tool code validates and formats JSON locally without uploading it. The public page also uses analytics and advertising; use synthetic or redacted input rather than live secrets.
Does formatting change my data?
The formatter preserves key order exactly as written. It only changes whitespace, so the parsed value is identical.
What is the maximum size?
There is no hard limit, but documents above a few megabytes may take a moment because they are processed in your browser.
Guides
Related tools
JSON Validator
Check whether a JSON document is valid and see exactly where it breaks.
JSON Minifier
Strip whitespace from JSON and see how many bytes you saved.
JWT Decoder
Decode the header and payload of a JSON Web Token and inspect its claims.
UUID Generator
Generate cryptographically random v4 UUIDs in bulk.
Regex Tester
Test regular expressions live with highlighted matches and capture groups.
Cron Expression Generator
Build and explain cron schedules in plain English.