JSON Formatter
JSON Formatter Guide
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Ctrl + Enter | Format JSON |
Ctrl + Q | Fold/unfold current block |
Tab | Insert 2-space indent |
JSON Syntax Reference
| Type | Example | Notes |
|---|---|---|
| Object | {"key": "value"} | Key-value pairs. Keys must be double-quoted strings |
| Array | [1, 2, 3] | Ordered list of values |
| String | "hello" | Must use double quotes. Single quotes are invalid |
| Number | 42, 3.14, -1, 2e10 | Integer or float. No NaN/Infinity |
| Boolean | true, false | Lowercase only |
| Null | null | Lowercase. Not None/nil/undefined |
Common JSON Errors & Fixes
{"a":1, "b":2,} — JSON standard doesn't allow trailing commas. Remove the last comma.
{'key': 'value'} — JSON only accepts double quotes. Replace all single quotes with double quotes.
{key: "value"} — Valid in JavaScript but not in JSON. All keys must be double-quoted.
{"a":1 // comment} — JSON doesn't support comments. Use JSON5 or JSONC format if you need comments.
Newlines and tabs in strings must be escaped: \n, \t. Raw control characters cause parse errors.
JSON vs Other Formats
| Feature | JSON | YAML | XML | TOML |
|---|---|---|---|---|
| Readability | Medium | High | Low | High |
| File size | Small | Smallest | Largest | Medium |
| Comments | No | Yes | Yes | Yes |
| Data types | 6 | Rich | All strings | Rich |
| Primary use | APIs, config | Config files | Documents, SOAP | Config files |
| Browser native | Yes | No | Yes | No |
FAQ
This tool processes JSON client-side in JavaScript, typically handling 5-10MB files. For larger files, use CLI tools like jq or python -m json.tool.
They're the same — both add indentation and line breaks to compressed JSON. This tool uses 2-space indentation (industry standard).
Python: python -m json.tool input.json
jq: jq '.' input.json
Node.js: node -e "console.log(JSON.stringify(JSON.parse(require('fs').readFileSync(0,'utf8')),null,2))"
💬 Comments
Frequently Asked Questions
Is this JSON formatter safe? +
Runs locally in browser, JSON never sent to any server.
What is the difference between JSON formatting and validation? +
Formatting makes JSON readable with indentation; validation checks if the JSON is syntactically correct. Both are essential for debugging.
How do I fix a JSON parse error? +
Paste your JSON here — syntax errors are highlighted with the line number. Common causes: missing quotes, trailing commas, unescaped characters.
How do I minify JSON? +
Use the Minify button to remove all whitespace. Minified JSON reduces API payload size by 20–40%.
What is JSON Schema? +
JSON Schema defines the expected structure and data types of JSON. Use it to validate API responses against a specification.