JSON formatter and validator
Paste JSON to make it readable and, if it is broken, see exactly where. Everything runs in your browser.
JSON is processed in your browser and never sent to a server. For very large inputs (several MB) syntax colouring is turned off for speed.
How to use
- Paste the JSON into the box; it is validated as you type.
- If it is valid, choose an indent and format, or minify it to one line.
- If it is not, go to the line and column shown; the pointer marks the exact spot.
- If comments or trailing commas are the problem, press “Repair and format”.
JSON's strict rules
JSON looks like JavaScript but is much stricter. Most parsers stop at the first violation, so a single stray comma invalidates the whole file.
| Rule | Valid | Invalid |
|---|---|---|
| Keys in double quotes | {"name": 1} | {name: 1}, {'name': 1} |
| Strings in double quotes | "hello" | 'hello' |
| No comma after the last item | [1, 2] | [1, 2,] |
| No comments | — | // note, /* note */ |
| Limited value types | string, number, true, false, null, object, array | undefined, NaN, Infinity, date objects |
There is no date type: dates travel as strings (usually ISO 8601) or as Unix timestamps. The timestamp converter turns those into readable dates.
Common errors and what they mean
| What you see | Why | Fix |
|---|---|---|
Unexpected } or ] | An extra comma before the closing bracket | Delete it or press “Repair” |
Unexpected ' | Single quotes were used | Switch to double quotes or press “Repair” |
| Unexpected end of input | An unclosed bracket or quote | Find the closer for every { [ " you opened |
| Unexpected letter | An unquoted key, or Python style True/None | Write true, false, null in lower case |
| Error at line 1, column 1 | An invisible BOM, or an HTML response | Check the source; the API may have returned an error page instead of JSON |
The reported position is sometimes after the real mistake: the parser only notices on the next character. Look just before the pointer too.
What “Repair” can and cannot do
- It does: remove
//and/* */comments, drop the comma before a closing bracket, turn single-quoted strings into double-quoted ones (escaping inner double quotes) and quote bare keys. - It does not: guess a missing bracket, restore a lost quote, or merge two separate JSON documents. Those are guesses that could change what the data means.
- The repaired result is always validated again; if something is still wrong, its position is shown.
- If you want to keep the comments in a config file, save the repaired version as a separate file.
Numbers: big ids and decimals
JSON itself puts no limit on number size, but most languages that read it do. JavaScript cannot hold integers above 2⁵³ − 1 (9,007,199,254,740,991) exactly.
- 17–19 digit ids from Twitter, Discord or databases can be rounded when formatted. That is why APIs also send them as strings (
id_str). - Decimal arithmetic such as
0.1 + 0.2is not exact; storing money as whole cents is safer. - Leading zeros (
007) and a plus sign (+5) are invalid in JSON.
Formatting, minifying and sorting
- Formatting (2 or 4 spaces, or tabs) is for reading and reviewing.
- Minifying strips whitespace and saves bandwidth and storage. If the server already gzips responses the gain shrinks, but it does not vanish.
- Sorting keys makes two JSON documents comparable: the same data in a different order no longer shows up as a difference. Compare two outputs line by line with the text compare tool.
Glossary
- JSON
- JavaScript Object Notation, a text-based data format (RFC 8259).
- Parse
- Read text and turn it into a data structure.
- Object
- Key–value pairs inside braces:
{"a": 1}. - Array
- Ordered values inside brackets:
[1, 2, 3]. - Minify
- Remove all unnecessary whitespace without changing meaning.
- JSON5
- A relaxed JSON variant that allows comments, trailing commas and single quotes.
- BOM
- An invisible byte-order mark at the start of a file; some parsers reject it.
- Escape
- Writing a special character inside a string, such as
\"or\n.
Frequently asked questions
What does a JSON validator do?
It reads the text by the JSON rules. If it is valid, it is formatted; if not, you see the line and column of the error, that line, and a pointer to the exact spot.
What does “Repair and format” fix?
Four things JSON forbids but people write all the time: // and /* */ comments, a comma after the last item, single-quoted strings and unquoted keys. They are corrected and the result is validated again.
What is the difference between formatting and minifying?
Formatting adds indentation and line breaks to make it readable. Minifying strips all unnecessary whitespace; the data is identical, just smaller. APIs and config files usually use the compact form.
Does sorting keys change the data?
No. Key order has no meaning in a JSON object; sorting only makes two files easier to compare. Array order is kept.
Why do large numbers change?
JavaScript numbers cannot hold integers above 2⁵³ exactly. An id such as 9007199254740993 may be rounded when formatted, so such ids belong in JSON as strings (in quotes).
Is my JSON sent anywhere?
No. Parsing, formatting and repair happen in your browser. Even if it contains API keys or personal data, nothing leaves the page.
How large a JSON can it handle?
Tens of megabytes, as long as the browser has the memory. Above 300 KB of output, colouring is switched off for speed, but formatting still happens.