How to format, validate and minify JSON online (with error positions)
API responses and config files often arrive on one unreadable line. JSON formatter makes them readable and tells you exactly what is wrong when they are not valid.
Steps
- Paste your JSON.
- Choose an Action: Format, Minify, Escape text into a JSON string, or Unescape a JSON string back to text.
- For formatting, pick the Indent (2 spaces, 4 spaces or tab) and optionally Sort keys alphabetically.
- Copy the result. It updates live as you type.
Fixing errors
Invalid input produces a message with the line and column, for example “Invalid JSON at line 3, column 5”. The usual causes:
- A trailing comma after the last item.
- Single quotes instead of double quotes.
- Unquoted keys (
{name: 1}is JavaScript, not JSON). - Comments, which JSON does not allow.
- A missing comma between items.
Escape and unescape
Escape turns any text into a JSON string literal, so quotes become \" and line breaks become \n. Use it to embed text in JSON. Unescape reverses it: paste "line one\nline two" and you get the two lines back.
Sorting keys
Sorting makes two JSON files easier to compare with Text diff, since key order no longer creates noise.
Limits
The tool follows strict JSON rules and does not accept JSON5 or comments. Very large files (many megabytes) may be slow in the browser.