JSON Formatter
Format, minify, sort keys, and validate JSON with readable errors. Fully client-side — no account, uploads, or remote storage.
Added Apr 18, 2026 · Updated Apr 29, 2026
Input
Result
Enter a value for action to see your result.
How it works
Formats, minifies, and validates JSON. Pretty-print with configurable indentation, minify for compact storage, or validate structure and report the exact line and column of any syntax error.
Step by step
- 01Paste your JSON into the input field.
- 02Choose Format to pretty-print, Minify to compact, or Validate to check syntax.
- 03For formatting, select 2 spaces, 4 spaces, or tab indentation.
- 04Errors show the line and column number of the problem.
Examples
Format JSON
Adds newlines and 2-space indentation.
Inputs
- Action:
- format
- Indent:
- 2
- JSON Input:
- {"name":"Alice","age":30}
Result
- Output:
- { "name": "Alice", "age": 30 }
- Status:
- Valid JSON
Minify JSON
Removes all whitespace.
Inputs
- Action:
- minify
- Indent:
- 2
- JSON Input:
- { "name": "Alice", "age": 30 }
Result
- Output:
- {"name":"Alice","age":30}
- Status:
- Valid JSON
More about this tool
All formatting, minifying, and validation happens entirely in your browser using the native JSON.parse() and JSON.stringify() APIs. Nothing is sent to a server.
Format vs Minify
Formatting adds indentation and newlines to make JSON human-readable. Choose 2 spaces (most common), 4 spaces, or a tab character.
Minifying removes all whitespace to reduce byte size — useful for API responses, localStorage values, and network payloads.
Error Reporting
When JSON is invalid, the formatter reports the exact line and column of the error by counting newlines up to the character offset returned by the JavaScript engine. Common errors:
- Trailing comma after the last item in an object or array
- Single quotes instead of double quotes around strings or keys
- Unquoted object keys
undefined,NaN, orInfinityvalues (not valid JSON)
Input Limit
Input is capped at 1 MB to keep the browser responsive. For larger files, use a local tool like jq.
Frequently asked questions
How do I fix a JSON syntax error?
The formatter reports the exact line and column where the error was found. Common mistakes: missing quotes around keys, trailing commas, using single quotes instead of double quotes.
What is the difference between formatting and minifying?
Formatting adds indentation and newlines to make JSON human-readable. Minifying removes all unnecessary whitespace to reduce file size, which is useful for API responses and storage.