JSON Formatter
Uses JavaScript's built-in JSON.parse() to validate and JSON.stringify(obj, null, 2) to indent with two spaces. Everything runs locally in your browser. Related: text case, unix timestamp, color converter.
Show the math
What Your Result Means
- Valid JSON: Your input follows JSON syntax rules and can be safely parsed and used by applications.
- Invalid JSON: Your input has a syntax error (missing bracket, incorrect quote, trailing comma, etc.). The error message indicates the position of the problem.
- Character Count: The input length (raw JSON) and output length (prettified JSON with whitespace) let you see the overhead of human-readable formatting.
How This Tool Works
This tool uses JavaScript's built-in JSON.parse() to validate your input against the JSON specification (RFC 8259). If valid, JSON.stringify() reformats it with two-space indentation for readability. All processing happens locally in your browser using no server calls, so confidential data stays on your device. Copy the prettified output for use in code, config files, or API requests.
Quick Questions
What is JSON?
JSON (JavaScript Object Notation) is a lightweight text format for structured data. It uses objects (key-value pairs with curly braces), arrays (square brackets), strings (double quotes), numbers, booleans, and null.
Why does my JSON fail to parse?
Common errors: missing or mismatched quotes, trailing commas, single quotes instead of double quotes, unescaped newlines in strings, or NaN/Infinity values. The error message pinpoints where the parser stopped.
Is my data secure when I paste it here?
Yes. All formatting runs entirely in your browser using JavaScript's built-in functions. No data is sent to servers, logged, or stored. Close the tab and it's gone.
Sources
- JSON.org — Official JSON specification and grammar
- MDN Web Docs: JSON — JavaScript JSON.parse() and JSON.stringify() documentation
- RFC 8259 — The JSON Data Interchange Format standard
Method & review
Estimate only. Results reflect your inputs and standard formulas. Double-check important decisions independently.