The JSON formatter turns compact or messy JSON into neatly indented text you can read, minifies it back into a single line, and checks that it's valid. Unlike most online formatters, it keeps your data exactly as you wrote it: very large numbers, duplicate keys and escaped characters come out unchanged.
How to format JSON
- Paste your JSON into the Input JSON box, or click Sample to try an example.
- Choose an indent of 2 spaces, 4 spaces or a tab.
- Click Format for readable, indented JSON, Minify for the smallest single-line version, or Validate to check it without changing it.
- Click Copy to copy the result.
Below the output you'll see the number of keys, how deeply the data is nested, and its size.
Why your numbers stay exactly the same
Most JSON formatters work by loading your JSON into JavaScript and writing it back out. That changes data in ways that are easy to miss.
JavaScript stores every number as a 64-bit floating-point value, which can represent whole numbers exactly only up to 9,007,199,254,740,991. Larger whole numbers are rounded. Database IDs, order numbers and IDs from systems such as Twitter's API are often bigger than that:
| You paste | Typical formatter returns | This formatter returns |
|---|---|---|
{"id": 12345678901234567890} | {"id": 12345678901234567000} | {"id": 12345678901234567890} |
The rounded number looks plausible, so the error can go unnoticed until a lookup fails. This tool formats the text itself instead of converting the values, so every number keeps all its digits. When it finds numbers that other tools would round, it tells you.
It works the same way for:
- Duplicate keys. JSON allows a key to appear twice in an object, but most programs keep only the last value. The formatter keeps both and warns you, because duplicates are usually a mistake.
- Escaped characters. Text such as
caféstays escaped instead of being converted tocafé, so the output matches what your system produced. - Number style.
1.50stays1.50and1E3stays1E3.
Common JSON errors and how to fix them
If your JSON isn't valid, the formatter shows the error message and the position where reading stopped. These are the most frequent causes:
| Problem | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1, "b": 2,} | {"a": 1, "b": 2} |
| Single quotes | {'name': 'Ann'} | {"name": "Ann"} |
| Unquoted keys | {name: "Ann"} | {"name": "Ann"} |
| Comments | {"a": 1 // note} | {"a": 1} |
| Special numbers | {"x": NaN} | {"x": null} |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
Many of these are allowed in JavaScript code, but not in JSON. Configuration files that accept comments, such as tsconfig.json, use a looser format called JSON with comments; strip the comments before validating them here.
Choosing an indent
- 2 spaces is the most common style for web projects and JavaScript.
- 4 spaces suits deeply nested data and matches the usual Python style.
- Tabs let each person set their own display width in their editor.
Minified JSON removes all optional whitespace. It's the version to send over a network or store, because indentation can make up a large share of a formatted file's size.
JSON formatter FAQ
Is my JSON sent to a server?
No. Formatting and validation run entirely in your browser, so you can safely paste API keys, tokens or customer data. Even so, it's good practice to remove secrets before sharing JSON with anyone.
Why does my formatted JSON keep keys in their original order?
The formatter never re-orders keys, so you can compare the output with the original line by line.
What does "Unexpected token" mean?
The validator found a character where JSON doesn't allow one. Look just before the position shown: the usual causes are a missing comma, a trailing comma, or single quotes.
Can it handle large files?
Yes. Files of several megabytes work on a typical computer, because everything is processed in your browser without a round trip to a server.
How do I turn JSON into a spreadsheet?
Use the JSON to CSV converter, which creates a file you can open in Excel or Google Sheets.