JSON Formatter
Format, validate and minify JSON with syntax highlighting and precise error locations.
Input
Output
Runs locally in your browser. Your input is not uploaded.
How to use the JSON Formatter
- Paste JSON into the input editor, or click Sample to try it.
- The formatted result appears instantly. Choose Format to pretty-print with 2 spaces, 4 spaces or tabs, or Minify to remove all whitespace.
- If the JSON is invalid, you'll see what's wrong, where (line and column), and how to fix it.
- Copy the result or Download it as a
.jsonfile.
What makes this formatter different
- Private. Formatting happens entirely in your browser. Your JSON is never uploaded, so it's safe for API responses, config files and tokens.
- Lossless. Numbers and strings are kept exactly as written. Many formatters parse JSON into JavaScript first, which silently rounds large IDs like
12345678901234567890to12345678901234567000and rewrites19.90as19.9. This one doesn't. - Helpful errors. Instead of a generic "Unexpected token", you get the exact position and a plain-English fix.
- Fast on large files. A 1 MB document formats in well under a second.
Example
Input:
{"id":1,"name":"Asha","roles":["admin","editor"],"active":true}Formatted with 2 spaces:
{
"id": 1,
"name": "Asha",
"roles": [
"admin",
"editor"
],
"active": true
}Common JSON errors it explains
- Trailing commas, like
{"a": 1,}. JSON doesn't allow a comma after the last item. - Single quotes, like
{'a': 1}. Strings and keys must use double quotes. - Unquoted keys, like
{a: 1}. Valid in JavaScript, but not in JSON. - Comments (
//and/* */). These aren't part of JSON. - Non-JSON values like
undefined,NaN, Python'sTrueandNone, or hex numbers like0x1F. - Missing commas, colons, brackets or braces, and unterminated strings.
Frequently asked questions
Is my JSON uploaded anywhere?
No. All processing runs in your browser with JavaScript. Nothing you paste is sent to a server or stored.
Does it validate the JSON too?
Yes. Every change is checked against the strict JSON standard (RFC 8259). You'll see "Valid JSON" when it's correct, or the first error with its line and column when it isn't.
Will formatting change my data?
No. Only whitespace between tokens changes. Keys, values, number formats, key order and string escapes like é stay exactly as they were.
Can it format JSON with comments (JSONC)?
Not yet. Comments aren't valid JSON, so the formatter points them out so you can remove them. That makes the output safe for any strict JSON parser.
What's the difference between Format and Minify?
Format adds line breaks and indentation so JSON is easy to read. Minify removes all unnecessary whitespace to make the file as small as possible, which is useful for APIs and storage. The status line shows the size before and after.