How to Format JSON Online: Parse and Prettify
To format JSON online, paste the text into a browser tool that runs JSON.parse and then JSON.stringify. Docify’s formatter prettifies with 2-space indentation, minifies to one line, and reports the parser error if the text is not standard JSON — no comments, trailing commas, or JSON5. Numbers larger than 253-1 lose precision when parsed; exponents like 1e309 overflow to Infinity and serialize as null. The formatter does not normalize Unicode — NFC é and NFD e + U+0301 remain as written. For Unicode normalization, see /unicode-normalize/. Nothing is uploaded.
Minified API payloads and one-line config files are hard to read. Formatting does not need a server: the browser already ships a JSON parser. The steps below use that parser, then point at the live JSON formatter.
What Prettify produces
The compact JSON below can be pasted into the formatter. Clicking Prettify parses it with JSON.parse and re-serializes with 2-space indentation. Numbers like age are preserved as JavaScript Number values, so 30 stays 30.
Why Format JSON?
- 👁️Readability - Formatted JSON is much easier to read and understand
- 🐛Debugging - Spot errors and issues quickly in properly indented JSON
- 📝Code reviews - Share clean, readable JSON with your team
- ✅Validation - A failed parse is an immediate syntax error
How to Format JSON in 3 Easy Steps
Step 1: Copy Your JSON
Copy the JSON data you want to format from your API response, file, or anywhere else. It can be minified, compressed, or messy.
Step 2: Paste into the JSON Formatter
Open the Docify JSON formatter and paste the text. Click Prettify to run JSON.parse and JSON.stringify with 2-space indentation. Nothing is uploaded.
Step 3: Copy Formatted Result
Copy the result and use it in an editor, a review, or docs. The values are the parsed JavaScript value serialized again — not a whitespace-only rewrite of the original string.
{
"name": "John Doe",
"age": 30,
"email": "john@example.com",
"address": {
"street": "123 Main St",
"city": "New York",
"country": "USA"
},
"hobbies": [
"reading",
"coding",
"gaming"
]
}JSON Formatting Options
Prettify / Beautify
Adds indentation and line breaks so humans can read the tree. Docify always uses 2 spaces via JSON.stringify(value, null, 2). There is no 4-space or tab option on this page.
Minify / Compress
Serializes the same parsed value to a single compact line (JSON.stringify with no space argument). Non-ASCII letters stay characters — see minify without breaking unicode. Useful when you want a smaller copy to paste back into a payload.
Validate
Runs the same JSON.parse step. On success you get a Valid JSON badge and the 2-space serialization. On failure the badge shows the browser’s parser message. The tool does not highlight a line gutter or re-check as you type. A complete exponent such as 1e309 parses as Infinity and that serialization is null; 1e308 stays a number.
A complete exponent such as 1e309 becomes null
Prettify is parse then stringify, not a whitespace-only rewrite. RFC 8259 §6 allows range limits and names 1E400 as a number that may not interoperate. JSON.parse("1e309") is Infinity; JSON.stringify then writes null, so {"n":1e309} becomes {"n":null}. 1e308 stays finite. 1e-324 underflows to 0. Write {"n":"1e309"} if the magnitude must survive. The Infinity token still fails parse.
Common JSON Errors & How to Fix Them
Trailing commas
JSON does not allow commas after the last item in arrays or objects.
Invalid:
Valid:
Single quotes
JSON requires double quotes for strings, not single quotes.
Invalid:
Valid:
Missing commas
Items in arrays and object properties must be separated by commas.
Invalid:
Valid:
Format JSON in the browser
Paste JSON, click Prettify, and get 2-space indentation. Standard JSON only. Nothing is uploaded.
Use JSON Formatter →FAQ
- How do I format JSON online?
- Paste your JSON, click Prettify. The tool parses it with JSON.parse and re-serializes with 2-space indentation.
- Does this tool upload my JSON?
- No. All formatting runs in your browser using JSON.parse and JSON.stringify. Nothing is sent to a server.
- What is the difference between Prettify, Minify, and Validate?
- Prettify adds indentation. Minify removes whitespace. Validate checks syntax and shows a pass/fail badge.
- Why does validation fail?
- Common causes: trailing commas, comments, single quotes, unquoted keys. Standard JSON requires double quotes.
- Why did my large number change?
- JSON.parse converts to JavaScript Numbers. Integers larger than 2^53-1 lose precision. Use strings for exact values.
Related
- Minify JSON Without Breaking Unicode
- Validate JSON Syntax with JSON.parse
- JSON vs YAML: Configuration Files
- Unix Seconds vs Milliseconds: UTC vs Local
- Convert JSON to CSV in JavaScript: Papa.unparse vs Papa.parse
- YAML 1.2 Core vs 1.1: Norway, Comments, JSON
- Need to export JSON to a spreadsheet? Try the JSON to CSV converter.
- Live tool: JSON formatter · Unicode NFC / NFD