What is a JSON formatter?
JSON (JavaScript Object Notation) is the text format most APIs, config files and apps use to exchange data. When it comes back from a server it is usually squeezed onto one long line, which makes it hard to read or debug.
A JSON formatter adds line breaks and indentation so you can see the structure at a glance. A validator checks that the JSON is correct and points to the exact line and column when it isn't. This tool does both, and it can also fix common mistakes for you.
How to use the JSON formatter
- Paste your JSON into the Input box, click Open file, or drag a
.jsonfile onto it. - Click Format (or press Ctrl + Enter). Pasting into an empty box formats automatically.
- If the JSON was broken, the yellow box tells you what was fixed. Click Replace input with fixed JSON to keep the repaired version.
- Explore the result: fold sections with the arrows, switch to the Tree tab, or search with Ctrl + F.
- Click any line to copy its path, then use Copy, Download or Share link to take the result with you.
Features
- Auto-fix broken JSONTrailing and missing commas, single quotes, unquoted keys, comments, Python True/None and cut-off brackets, with a list of every change.
- Unwrap escaped JSONPaste
{\"id\":1}or stringified JSON from logs and it is unescaped automatically. - Code and Tree viewsLine numbers, fold arrows and syntax colors, or a collapsible tree with item counts.
- Copy pathsClick any value to copy its path, like
data.users[3].email, or copy the value itself. - SearchFind keys and values with a match counter. Folded sections open automatically.
- Share by linkThe JSON lives inside the link, so nothing is stored on a server.
- Big filesHandles files of around 20 MB in the background without freezing the page.
- Private by designEverything runs in your browser. Files and pasted text are never uploaded.
- Keyboard and dark modeEvery action works from the keyboard, with light, dark and automatic themes.
Example: fixing broken JSON
This is valid JavaScript but not valid JSON:
{
name: 'Alex', // unquoted key, single quotes
active: True, // Python-style boolean
tags: ['js', 'ts',], // trailing comma
}
Auto-fix turns it into valid JSON and lists every change it made:
{
"name": "Alex",
"active": true,
"tags": ["js", "ts"]
}
Common JSON errors and how to fix them
These are the messages browsers, Node.js and Python show when JSON is invalid. Paste the JSON above and the formatter points to the exact line and column, and fixes most of them for you.
| Error message | What it usually means | How to fix it |
|---|---|---|
Unexpected end of JSON input | The JSON is cut off, or the response was empty. | Check that the whole response arrived. Add the missing } or ]. |
Expected double-quoted property name / Expecting property name enclosed in double quotes | A key has no quotes, single quotes, or there is a trailing comma before }. | Wrap every key in double quotes and remove the last comma. |
Unexpected token '<', "<!DOCTYPE "... is not valid JSON | The server sent an HTML page (often an error or login page) instead of JSON. | Open the URL in your browser and check the status code and the real response. |
"undefined" is not valid JSON | JSON.parse was given undefined, usually a missing value in localStorage or a variable. | Check the value exists before parsing it. |
Bad control character in string literal | A string contains a raw line break or tab. | Write line breaks as \n and tabs as \t inside strings. |
Unexpected token 'T' / 'N' | Python values like True, False or None. | Use true, false and null. |
Frequently asked questions
Is my JSON uploaded anywhere?
Why does it say my JSON is invalid?
undefined or True. The error message shows the exact line and column. With Auto-fix on, most of these are repaired automatically.What is the difference between Format and Minify?
How do I get the path to a value?
orders[0].customer.email, appears under the output and is copied to your clipboard. Keys with spaces or dashes use bracket style, like user["first name"].