JSON Formatter
Format, beautify and minify JSON with instant validation — all in your browser.
Beautify, validate and minify JSON instantly — everything stays in your browser. Free. No sign-up. Runs in your browser, nothing is uploaded.
Output
Your formatted JSON will appear here.Paste JSON and press Format to pretty-print it with 2 or 4 spaces, or Minify to squeeze it onto one line. If it is not valid, you get the parser's message plus the line and column where it broke, so you can jump straight to the problem. The indent width is remembered for next time; your JSON is not.
Error messages and what usually causes them
The message comes from your browser's JSON parser, so the wording differs a little between Chrome, Firefox and Safari. The underlying causes are always the same handful:
| Message mentions… | Usual cause | Example |
|---|---|---|
| "Expected double-quoted property name" | A trailing comma before } | {"a": 1,} |
Expected property name or '}' | A key without quotes, or in single quotes | {a: 1} or {'a': 1} |
"Unexpected token" followed by a quote ' | A single-quoted value | {"a": 'x'} |
| "Unexpected token" at the very start | Text before the JSON: a log prefix, data: , a BOM | data: {"a":1} |
| "Unexpected end of JSON input" | A bracket or brace never closed, or a truncated copy | {"a": [1, 2} |
Expected ',' or '}' after property value | Missing comma between two entries | {"a": 1 "b": 2} |
| "Bad control character in string" | A real line break or tab inside a string | Use \n instead |
"Unexpected token" at N, u or I | NaN, undefined or Infinity — not JSON values | {"x": NaN} |
The line and column point to where the parser gave up, which is often one character after the real mistake. With a missing comma, look at the end of the previous line.
JavaScript object or JSON? The differences that bite
Copying an object straight out of code is the most common reason a paste fails. JSON is stricter than JavaScript:
- Keys need double quotes:
{"name": "x"}, never{name: "x"}. - Strings need double quotes:
'hello'is not JSON. - No trailing commas in arrays or objects.
- No comments, neither
//nor/* */. - Only six value types: string, number,
true/false,null, array, object. Noundefined,NaN, dates or functions — dates travel as strings such as"2026-11-30".
Things formatting quietly changes
Formatting re-prints the parsed data, so a few details of your original text are not preserved:
-
Number spelling is normalized.
1.0becomes1,1e2becomes100,-0becomes0. -
Unicode escapes are written out.
"café"comes back as"café". It is the same string, but a text diff will flag it. -
Duplicate keys collapse to the last value, as described in the FAQ.
-
Huge integers lose digits. The tool warns you whenever a whole number above 2^53 − 1 is in the input. Numbers too large or too small for JavaScript at all (like
1e400) trigger a separate warning, because they turn intonullor0. -
Number-like keys move to the front. Key order is otherwise kept as written, but JavaScript always lists integer keys first and in ascending order:
{"b": 1, "2": 0, "1": 0}comes out as{"1": 0, "2": 0, "b": 1}.
2 spaces, 4 spaces or minified?
- 2 spaces is the common default in JavaScript projects and API documentation, and keeps deep nesting from running off the right edge.
- 4 spaces is easier to scan for shallow, wide objects and matches what Python writes with
json.dumps(data, indent=4). - Minified is for sending and storing. Deeply nested, indented JSON can spend a surprising share of its bytes on spaces and line breaks; minifying removes all of them. Gzip compression on a server narrows that gap, so the gain matters most for stored files and size-limited fields.
If the JSON lives in a Git repository, keep it pretty-printed with one consistent indent: a change then shows up as a one-line diff instead of one giant modified line.
Switching between 2 and 4 re-indents the current output straight away. Pasting a minified blob, formatting it to read, then minifying it again before pasting it back is the everyday workflow.
Next steps for the same data
Need the data in another shape? The JSON ↔ CSV Converter turns an array of objects into a spreadsheet, the JSON ↔ YAML Converter handles config files, and JSON to TypeScript writes interfaces from a sample payload.
Frequently asked questions
Related tools
All Developer tools →- Base64 Encoder / DecoderEncode text to Base64 or decode it back — instantly and privately in your browser.
- URL Encoder / DecoderEncode or decode URLs and query components instantly and privately in your browser.
- Hash GeneratorGenerate SHA-1, SHA-256, SHA-384 and SHA-512 hashes of any text — privately in your browser.
