JSON Formatter & Validator — Fix, Format, and Debug JSON Online
Paste messy JSON, get clean output. This tool formats, validates, and minifies JSON right in your browser — nothing gets sent to a server. If your JSON has errors, it tells you exactly which line is broken and why.
JSON in 60 Seconds
JSON (JavaScript Object Notation) is the standard format for moving data between servers and browsers. Every REST API you've ever called returns JSON. Every package.json, tsconfig.json, and .eslintrc file on your machine is JSON.
The format is dead simple — objects use curly braces, arrays use square brackets, strings need double quotes. But the simplicity is deceptive. There's no comment syntax, trailing commas are illegal, and a single misplaced comma will break the entire document. That's where a formatter with validation comes in.
JSON is defined in RFC 8259 (December 2017). The spec is only 16 pages. The rule most people trip over: object keys MUST be strings in double quotes. {name: "John"} is valid JavaScript but invalid JSON. Another gotcha — despite the name, JSON isn't a strict subset of JavaScript. Characters U+2028 and U+2029 are valid in JSON strings but were illegal in JS string literals until ES2019.
How to Use
- Paste or type your JSON into the input area on the left.
- Pick your indentation — 2 spaces (JS/TS convention) or 4 spaces (Python convention).
- Hit "Format" to pretty-print, or "Minify" to strip all whitespace.
- Copy the result. If there are errors, the validator highlights the exact line and character.
When You'll Actually Use This
Debugging API responses
Your fetch() returns a 2000-character blob. Paste it here to see the nested structure. Way faster than console.log(JSON.stringify(data, null, 2)) when you're jumping between multiple endpoints.
Validating config files before deploy
Caught a trailing comma in your CloudFormation template? That's a 20-minute deploy failure you just avoided. Paste any JSON config here before pushing — the validator catches what your editor's syntax highlighting misses.
Cleaning up database exports
MongoDB dumps and Firestore exports come as massive single-line JSON. Format it to find that one document with the weird null field that's crashing your migration script.
Preparing JSON for documentation
Need to show a JSON example in your API docs or README? Format it with 2-space indent, copy, paste into your markdown code block. Done in 5 seconds.
Tips from Experience
Always validate before you parse
Wrap JSON.parse() in try-catch. Always. An unhandled JSON parse error in production will crash your Node process or show users a white screen of death.
Watch out for copy-paste encoding issues
Smart quotes from Slack/Word (“” instead of ""), invisible BOM characters from Windows Notepad, and non-breaking spaces from web pages — all will break valid-looking JSON. If the validator says error at position 0, it's probably an invisible character.
Know when NOT to use an online tool
For files over 10MB, use jq on the command line. For automated formatting in CI, use prettier or python -m json.tool. This tool is for quick manual debugging at your desk, not pipeline automation.
2 spaces vs 4 spaces
JSON spec doesn't care. But JS/TS projects overwhelmingly use 2 spaces (check any popular open source repo). Python projects tend to use 4. Pick one and be consistent across your team.
Real-World Examples
Nested API response
A typical user profile response from a REST API — minified as it arrives over the wire.
Input
{"id":42,"name":"Jane","email":"[email protected]","roles":["admin","editor"],"preferences":{"theme":"dark","locale":"en-US","notifications":{"email":true,"push":false}},"lastLogin":"2026-05-10T14:30:00Z"}Output
{
"id": 42,
"name": "Jane",
"email": "[email protected]",
"roles": [
"admin",
"editor"
],
"preferences": {
"theme": "dark",
"locale": "en-US",
"notifications": {
"email": true,
"push": false
}
},
"lastLogin": "2026-05-10T14:30:00Z"
}Invalid JSON — spot the error
This looks right at first glance, but has a trailing comma that breaks strict JSON parsing.
Input
{"users": [{"name": "Alice", "age": 30,}, {"name": "Bob", "age": 25}]}Output
Error at position 38: Unexpected token '}'. Trailing comma after "30" is not allowed in JSON. Remove the comma to fix.Features
- Formats JSON with 2 or 4 space indentation — your choice
- Validates and pinpoints errors to the exact line and character
- Minifies JSON in one click for production use
- Runs 100% in your browser — zero data sent anywhere
- Handles files up to ~50MB (tested with production MongoDB dumps)
- No signup, no ads, no tracking
Frequently Asked Questions
My JSON looks valid but the parser says "unexpected token" — what gives?
Nine times out of ten it's one of these: (1) trailing commas — {"a": 1,} is invalid, (2) single quotes — JSON requires double quotes only, (3) unquoted keys — {name: "John"} is JS but not JSON, (4) comments — // and /* */ aren't allowed in standard JSON. If you need comments, look into JSONC or JSON5.
Is there a file size limit?
No hard limit on our end — it runs in your browser's memory. Chrome handles up to ~100MB before tabs start crashing. For anything over 10MB, you'll get better performance with jq or fx on the command line.
Does this tool phone home with my data?
No. Zero network requests after the page loads. Open DevTools → Network tab, paste your JSON, click format — nothing fires. The entire tool is client-side JavaScript.
What's the difference between JSON and JSONC?
JSONC (JSON with Comments) allows // and /* */ comments plus trailing commas. VS Code uses it for settings.json and tsconfig.json. Standard JSON parsers will reject JSONC — you need a JSONC-aware parser like the jsonc-parser npm package.
Why does JSON not allow trailing commas?
It's a deliberate design choice from the spec to keep parsing simple and unambiguous. JavaScript allows them, Python allows them, but JSON doesn't. Most "invalid JSON" errors in the wild come from developers assuming JSON follows the same rules as their programming language.
Tips & Related Workflows
- Need to encode your formatted JSON for a URL parameter? Use our URL Encoder/Decoder.
- Working with API tokens? Decode Base64-encoded JSON payloads with our Base64 Encoder/Decoder.
- Validate your regex patterns before using them in JSON schema with our Regex Tester.
- Generate unique identifiers for your JSON objects with our UUID Generator.