Developer Tools
JSON Formatter
Paste JSON to pretty-print it with clean indentation, validate it (with clear error messages) or minify it to a single line. Everything runs in your browser — your data is never uploaded.
How to format, minify or check JSON
- Paste your JSON into the box. It opens with a short sample object so you can try the buttons first.
- Press Format (2 spaces) or Format (4 spaces) to pretty-print, or Minify to collapse it onto one line.
- If the text is not valid JSON, a red box shows the parser's message and the result area is cleared. Fix the input and press the button again.
- Copy the result with the Copy button in the result header.
What each button actually does
All three buttons parse the input with the browser's JSON.parse and write it back out with JSON.stringify. The two Format buttons pass an indent of two or four spaces; Minify passes no indent, which removes every line break and every space outside string values. Spaces inside strings are kept, so the sample's All Day Toolkit stays intact.
On the sample object the three outputs are 75 characters minified, 105 characters with two-space indentation and 123 with four. Formatting also normalises the layout: one property per line, arrays expanded one element per line, and a single space after each colon. There is no option to keep short arrays on one line or to sort keys.
Reading the error message
The text in the red box comes straight from the browser, so the wording differs between Chrome, Firefox and Safari, but every browser reports a position. In Chrome the position is a zero-based character offset, followed in recent versions by a line and column. Count from the start of your text, or paste it into an editor that shows column numbers, to land on the exact spot.
| Mistake | Example input (quotes shown as ‘ ’) | Chrome's message |
|---|---|---|
| Trailing comma | {‘a’:1,} | Expected double-quoted property name in JSON at position 7 |
| Single-quoted or unquoted key | {a:1} | Expected property name or '}' in JSON at position 1 |
| Missing comma between properties | {‘a’:1 ‘b’:2} | Expected ',' or '}' after property value in JSON at position 7 |
| Extra closing bracket | {‘a’:1}} | Unexpected non-whitespace character after JSON at position 7 |
| Empty box | Unexpected end of JSON input |
Things the round trip changes silently
- Integers above 2^53 lose precision: an id of 12345678901234567890 comes back as 12345678901234567000. Do not reformat files containing 64-bit identifiers such as Twitter or Discord snowflakes.
- Numbers are normalised: 1.0 becomes 1 and 1e3 becomes 1000.
- Duplicate keys collapse to the last one. {‘a’:1,‘a’:2} formats as a single a with the value 2.
- Keys that look like whole numbers are moved to the front in ascending order, so an object with keys b, a, 10, 2 is written out as 2, 10, b, a. All other keys keep their original order.
- Escapes are resolved: \u00e9 becomes é and \/ becomes a plain slash.
What counts as valid here
The parser follows RFC 8259 strictly. Comments, trailing commas, single quotes, unquoted keys, hexadecimal numbers, NaN, Infinity and undefined are all rejected. Files in the looser JSONC or JSON5 dialects, including tsconfig.json and VS Code settings with comments, will fail until the comments and trailing commas are removed. On the other hand, any JSON value is accepted at the top level, so a bare number, a string in quotes or an array formats fine.
Everyday uses
- Reading an API response copied from curl or a browser's network tab, where everything arrived on one line.
- Checking a webhook payload or a config file for a stray comma before deploying.
- Minifying a JSON blob before pasting it into an environment variable, a data attribute or a command-line flag.
- Comparing two responses: format both with the same indent, then diff them in your editor.
What the formatter leaves out
There is no collapsible tree view, syntax colouring, key sorting or schema validation; the output is a plain read-only text box. Multi-megabyte payloads parse fine, but scrolling a very large text box can be slow, so for files of that size an editor is a better fit.
Frequently asked questions
Is my JSON sent to a server?
No. The formatting, validation and minifying all happen locally in your browser using the built-in JSON engine, so your data never leaves your device.
What happens if my JSON is invalid?
The tool shows the exact parser error message so you can find the problem — for example a missing comma, an unquoted key or a trailing bracket.
Why did a long numeric id change after formatting?
JavaScript stores numbers as 64-bit floats, which are exact only up to 2^53. Longer integers are rounded when parsed, so the formatted output differs from the input. Quote such ids as strings in the source if you can.
Why are my keys in a different order?
Keys that are whole numbers are written first in numeric order; every other key keeps its original position. This is how JavaScript objects order their properties and cannot be switched off.
Can it format a file with comments, such as tsconfig.json?
No. Comments are not part of JSON, so the parser reports an error at the first slash. Remove the comments and any trailing commas first.
Does minifying change the data?
Only whitespace outside strings is removed. Values and keys are untouched, apart from the number and key-order normalisation that applies to every parse.
Explore
113 tools. Zero uploads. One place.
Every tool opens instantly, works on your phone and keeps your files on your device.
JSON Formatter guides
Related tools
Base64 Encode / Decode
Developer Tools
Encode text to Base64 or decode it back.
Open toolURL Encode / Decode
Developer Tools
Percent-encode or decode URLs and query strings.
Open toolUUID Generator
Developer Tools
Generate random UUID (v4) identifiers in bulk.
Open toolColor Converter
Developer Tools
Convert colors between HEX, RGB and HSL.
Open tool