JSON formatter and validator
Paste JSON, read it properly. If it is broken you get the line, the column and what is actually wrong.
Paste some JSON and it formats itself.
What a JSON formatter and validator does
It takes JSON that is unreadable, or broken, and tells you which one it is. Paste it above and you get it back indented and coloured, with the number of keys, the deepest level of nesting, the number of array items and the size before and after. If it will not parse you get the line, the column, the offending line with the spot marked, and a sentence about what is probably wrong.
That last part is the reason this page exists. A browser tells you
Unexpected token } in JSON at position 1472 and leaves you counting characters. A
character offset is useless to a human. This page turns 1472 into line 61, column 3, prints the
line, points at it, and names the cause: an extra comma, a single quote, a key without quotes,
or a brace that never closed.
Everything here is JavaScript running in your tab. There is no server to send anything to. Open the network panel in devtools and watch it stay silent, or load the page, turn your wifi off, and keep using it.
How to read a JSON syntax error
Look at the line it names, then at the token just before the one it points at. A JSON parser reports where it gave up, not where you went wrong, and those two places are usually one token apart. A stray comma on line 60 surfaces as a complaint about the closing brace on line 61. That one habit solves most of them.
These four cover the large majority of real failures.
An extra comma before a closing brace or bracket
The commonest one by a long way. JavaScript and Python both allow a comma after the last item. JSON never has, in any version.
{
"tags": ["a", "b",],
"ok": true,
}
Both of those commas have to go. This page reports the position of the comma itself rather than the bracket after it, and offers a button that deletes it.
A single quote where a double quote belongs
Valid JavaScript, invalid JSON. JSON has exactly one string syntax and it uses double quotes.
If this came out of a console.log of an object, or out of Python's print,
expect every quote in the document to be wrong.
{ 'city': 'Dhaka' } wrong
{ "city": "Dhaka" } right
A key without quotes
Object keys in JSON are always quoted strings. Bare keys are fine in a JavaScript object literal and in YAML, which is how they get in here.
{ city: "Dhaka" } wrong
{ "city": "Dhaka" } right
A brace or bracket that never closes
Usually a block that got half deleted. When the document runs out while something is still
open, this page tells you the line the orphan { was opened on and how many levels
are still open, which is the information you need to find it. Counting braces by eye in a 2000
line file is how people lose an afternoon.
Why JSON.parse says unexpected token
Because it hit a character that cannot legally start or continue a value at that point. The character it names is nearly always innocent. Common causes, past the four above:
| What you see | What it usually is | Fix |
|---|---|---|
| Unexpected token at position 0 | An invisible byte order mark in front of the first brace, added by some editors when saving | Strip the first character. This page detects it and offers a button |
| Unexpected token N | NaN, which JSON has no syntax for | Write null, or a string |
| Unexpected token I | Infinity from a division that went wrong upstream | Write null |
| Unexpected token u | undefined leaked from JavaScript | Write null. JSON.stringify drops undefined properties, so real output never has it |
| Unexpected token T or N | Python output: True, False, None | Lowercase true and false, and null |
| Unexpected token / | A comment. Plain JSON allows none | Delete it, or switch the reader to JSON5 or JSONC |
| Bad control character in string | A real line break or tab inside a string | Escape it as \n or \t |
| Unexpected non whitespace character after JSON | Two or more documents in one file | That is JSON Lines. Tick the JSON Lines box above |
| Unexpected number | A leading zero, like 007, or 1_000, or hex | Quote it if the zeros matter, otherwise write it plainly |
Does formatting JSON change the data
No. Indentation, line breaks and spaces between tokens carry no meaning in JSON, so adding or removing them leaves the data identical. Two things here do change bytes, and both are deliberate: minifying strips that whitespace, and sorting keys reorders object members. Key order is not part of what an object means in JSON, though plenty of code quietly depends on it, so sort only when you want a stable order for a diff. Sorting is by code point, so uppercase keys land before lowercase ones, the same as most diff tools.
One thing this page does that many do not: large numbers survive. A formatter built on
JSON.parse turns 9007199254740993 into 9007199254740992,
because that is the nearest value a double can hold. This one keeps number text exactly as you
typed it, so IDs and currency values come out the other side unharmed.
JSON to CSV and CSV to JSON
Both directions are on this page because they share the same parser. Going to CSV, an array of
objects becomes one row per object, columns are the union of every key in the order first seen,
and nested objects flatten to dotted column names like address.city. Arrays inside
a row flatten by index, so tags.0 and tags.1. A null
becomes an empty cell.
The part most converters get wrong is quoting. A field containing the separator, a double quote
or a line break has to be wrapped in double quotes, and any double quote inside it has to be
doubled. So she said "hi" is written "she said ""hi""". Get that wrong
and the row silently splits in two when somebody opens it in a spreadsheet. This page follows
RFC 4180 and ends lines with a carriage return and newline pair, which is what spreadsheets
expect.
One thing to know before you open the result in Excel: a cell whose text starts with
= or + or @ gets treated as a formula by spreadsheet
software. That is a real risk if the data came from strangers. This page does not mangle your
values to work around it, so if that applies to you, review the file first.
Coming back from CSV, the first row becomes the keys unless you untick the box. Duplicate
column names get a numbered suffix instead of overwriting each other, which is the bug in most
quick scripts. Rows with too few cells get null for the missing keys, rows with too
many get numbered extra keys, and you are told how many rows were ragged rather than losing them
quietly. Numbers and true, false, null are read as
themselves, but only when the text is already valid JSON, so a postcode like
01205 and a phone number stay strings.
What JSON Lines is
One JSON document per line, no wrapping array, no commas between them. It is what logs,
exports and streaming APIs use, because you can append a record without rewriting the file and
read it one line at a time without holding the whole thing in memory. The extensions are
.jsonl and .ndjson.
Tick Input is JSON Lines to read it, and pick JSON Lines under Output to write it. If you paste JSON Lines without ticking the box, the parser stops at the end of the first document and says so, and the error offers to switch the box for you. Going the other way, an array becomes one line per item, which is how you feed a large export into something that streams.
How big a file can this handle
Ten megabytes, which covers nearly everything anyone pastes into a browser. Above that it refuses and tells you the size, rather than hanging the tab. Four things ease off on the way up: automatic formatting as you type stops above 512 KB and waits for the button, colouring stops above 300 KB of output because the markup costs more than it gives, only the first 2 MB of a result gets drawn on screen while Copy and Download still hand over all of it, and the tree view builds branches only when you open them, in batches of 200 children.
Typing is debounced, so a key press never triggers a parse until you stop for a moment. The parser is a single pass with its own stack rather than a recursive one, which means deeply nested documents do not blow the call stack the way a naive formatter does.
Is it safe to paste production data here
Yes, as far as this page is concerned, because the data never leaves your browser. There is no upload, no API call, no analytics on what you paste, and no copy kept anywhere. The only thing stored on your device is your choice of indent and the switches, under one localStorage key, so the page comes back the way you left it. Your JSON is not saved, not even locally.
The honest caveat has nothing to do with us: a shared or managed machine can have a browser extension reading the page, and that is true of every tool of this kind, including the ones that do send your data to a server. If the content is genuinely sensitive, run a formatter offline. This page works with the network off, so saving it and opening the file is a reasonable option.
Related tools
Everything here runs in your browser. Nothing you type is sent anywhere or stored.