Code Tools
JSON Formatter & Validator
Paste or type any JSON to validate, pretty-print or minify it instantly. All parsing happens locally in your browser — no data is uploaded or sent anywhere.
Input
Output
Output will appear hereHow it works
The formatter pipes your input through JSON.parse, the browser's native parser. Valid JSON must be UTF-8, use double-quoted strings, and contain only six value types — objects, arrays, strings, numbers, booleans, and null. Property names must be quoted, numbers cannot carry leading zeros, and trailing commas are rejected. On success the tool re-serializes with JSON.stringify: pretty-print mode passes a null replacer plus an indentation argument of 2 or 4 spaces, while minify mode omits the indentation so all whitespace is stripped. On failure the engine's error message is parsed to report the exact line and column — V8 reports “at position N” while SpiderMonkey reports “line X column Y” — so you can jump straight to the fault. The result is validated live as you type, so the Valid or Invalid badge updates on every keystroke.
Use cases
Pretty-print API responses returned by curl or Postman, inspect minified bundles, validate config files before deployment, tidy log entries into readable diffs, or teach JSON syntax. Because nothing leaves the browser, it is also a safe place to reformat tokens and payloads you would rather not paste into a remote service. It also normalizes whitespace before you commit JSON to source control, so diffs stay clean and reviewable.
Troubleshooting
- “Unexpected token” — look for single quotes, unquoted keys, or a trailing comma.
- “Unexpected end of JSON input” — usually a missing closing brace or bracket.
- “Unexpected token” at position 0 — the file may carry a UTF-8 byte order mark (BOM, U+FEFF). Re-save it without a BOM, or strip the leading U+FEFF character before parsing.
- Duplicate keys collapse silently —
JSON.parsekeeps only the last occurrence, so run a linter if duplicates matter. - Large inputs freeze — parsing is synchronous, so multi-megabyte documents may stall the tab.
- Precision loss — numbers are IEEE 754 doubles, so integers larger than 2^53 lose precision on re-serialization.
FAQ
Is my JSON data uploaded or stored anywhere?
No. Parsing, formatting, and minification all run locally in your browser using the native JSON API. Nothing you paste is sent to a server or saved.
What is the difference between 2-space and 4-space indentation?
It is purely cosmetic. Both produce valid, equivalent JSON — the spacing only changes how the output is visually aligned when you read it.
Why does my JSON fail with "Unexpected token"?
JSON is stricter than JavaScript object literals. Single quotes, trailing commas, and unquoted property names are all invalid. Use double quotes around strings and keys, and remove any trailing comma.
Can I format very large JSON files?
Files up to a few hundred kilobytes format instantly. Multi-megabyte inputs may briefly block the tab because JSON.parse is synchronous, so split large documents first.
Does minifying change my data?
No. Minify only removes whitespace and formatting. The parsed value and its field order are preserved exactly.