JSON formatter that leaves your data alone
Most formatters parse your JSON and print it back from memory, which silently reorders keys, rounds big integers and hides duplicate keys. This one rewrites the text itself: what you paste is what comes back.
Parsed by this site rather than by the browser, so key order, integers past 2^53 and duplicate keys all come back exactly as you wrote them.
When you need this
- A config file will not load and the error says
position 1847. You need the line, the column, and what the parser expected at that spot. - You paste an API response to read it, and the IDs come back with a trailing zero that was never in the payload.
- A JSON document has to travel inside a string field, so it must be escaped on one side and unescaped on the other.
Why other JSON viewers quietly change your data
They format by parsing and re-printing. JSON.parse turns {"2":"b","1":"a"} into keys 1,2 because JavaScript orders integer-like keys numerically, turns 1234567890123456789 into 1234567890123456800, and throws away the first copy of a duplicate key without a word. The output looks tidy and is no longer your data.
They report errors as an offset. Unexpected token ] in JSON at position 42 does not tell you the line, what was expected there, or that a trailing comma caused it.
They fold escaping into formatting. Escaping is a string operation; run it through a parser and it stops working exactly when your JSON is broken, which is when you need it most.
Why this page does not use JSON.parse
Every formatter you have used before this one, including the console in your browser, formats by parsing the document into a JavaScript value and printing that value back out. It is a convenient design, and on three kinds of input it changes your data without saying so.
The first is key order. A JavaScript object is not an ordered map for integer-like keys: {"2":"b","1":"a"} comes back as {"1":"a","2":"b"}. If you are comparing two payloads, or checking whether a server preserved the order it promised, the tool has just destroyed the thing you were looking at.
The second is large integers. JavaScript numbers are IEEE-754 doubles, exact only up to 2^53 - 1 = 9,007,199,254,740,991. A snowflake ID, a database bigint primary key or a nanosecond timestamp is routinely longer than that, and the moment it passes through Number the last digits change. The formatter prints the rounded value and you copy it into a bug report.
The third is duplicate keys. {"a":1,"a":2} is legal JSON; the specification says the names should be unique but does not say what to do when they are not. Every mainstream parser keeps the last one and discards the rest. A formatter built on top of one shows you a document with a single a and no hint that a second one existed.
So this page does not parse to a value. It scans the text into tokens, keeps each token’s original spelling, and re-emits those tokens with new whitespace. Numbers never pass through Number. Keys are emitted in the order they appear. A duplicate key stays in the output and is reported separately, with the line numbers of both copies.
The 2^53 line, and where it bites
A double has 53 bits of significand. Every integer up to 9,007,199,254,740,991 is exact; above that the gap between representable numbers is 2, and it doubles again at each power of two. 9007199254740993 cannot be stored at all — it becomes 9007199254740992.
This is not an edge case you can ignore. Twitter/X snowflake IDs passed 2^53 in 2010 and are now around 19 digits. PostgreSQL bigint columns go to 9.2 × 10^18. Unix timestamps in nanoseconds (the default in Go, Java Instant, and the Linux kernel’s CLOCK_REALTIME) are 19 digits today. Any of them survives a trip through JSON text and loses its tail the moment something parses it into a double.
That is why this page shows the number exactly as written and puts a warning next to it: the JSON is fine, the number is fine, but whatever reads this document next is likely to mangle it. The fix is on the producer’s side — send large IDs as strings — and the warning is what tells you to go and look.
Duplicate keys: allowed, undefined, silently merged
RFC 8259 says the names within an object SHOULD be unique. SHOULD, not MUST, and it adds that when they are not, the behaviour is unpredictable: implementations may report the last value, the first value, or fail. In practice the last one wins everywhere, quietly.
Duplicates appear more often than people expect. Two config fragments get concatenated. A merge tool appends instead of replacing. A serializer writes the same field twice because two code paths both set it. The document is still valid JSON, every tool accepts it, and one of the two values has already disappeared.
When this page sees the same key twice in one object it keeps both in the output and reports the line numbers of each. That is the only way to see which one is being used: compare the two lines and decide which is stale.
JSON has no comments, and that is deliberate
Douglas Crockford removed comments from JSON on purpose: he had seen people put parsing directives in them, which turns a data format into a program. The result is a format that can be parsed without any knowledge of the producer, and that is why it won.
It also means a file with // or /* */ in it is not JSON, no matter how much it looks like one. This is the most common reason a config file "does not work": the editor highlights it nicely because it treats .json as JavaScript, and the loader rejects it at the first slash. The error this page gives you names comment as the cause and points at the exact column.
If you need comments, use a format that has them — JSONC for editor configs, JSON5 for a more forgiving syntax, YAML if you like indentation. Converting to plain JSON later is a build step, not something to do by hand.
Trailing commas and single quotes come from JavaScript
Both are legal in a JavaScript object literal and neither is legal in JSON. That is the whole story, and it explains almost every Unexpected token on a hand-written file: the author wrote what the language they use every day accepts.
JavaScript has allowed trailing commas in object and array literals since ES5, and in function calls since ES2017. Python allows them in any collection. JSON does not, because a comma in JSON separates two members and there is no second member to separate.
The same goes for single quotes and for unquoted keys. {a: 1} is a JavaScript object; in JSON the key must be a double-quoted string, and 'a' is not one. This page reports each of these by name rather than as a syntax error at an offset.
Frequently asked questions
Is my JSON uploaded anywhere?
No. Everything runs in this page: the tokenizer, the formatter and the tree are plain JavaScript loaded with the page, and there is no network call in any of them. You can disconnect and it keeps working.
Why do keys keep their order here but not in other tools?
Because this page never converts your document into a JavaScript object. It scans the text into tokens and prints those tokens back in the order they appeared. Any tool that calls JSON.parse and then JSON.stringify will reorder integer-like keys, since a JavaScript object sorts them numerically.
How much can I paste at once?
Up to 10 MB of text, the same limit as the other tools on this site. Above that the page stops and says so instead of freezing, because a token stream that large will block the tab.
Is the sort option safe to leave on?
It changes your output, so it is off by default and says so while it is on. Keys are compared as plain text, which means "10" sorts before "9" and uppercase before lowercase. Array order is never touched.
Does this understand JSON5, JSONC or JSONPath?
No, and that is on purpose. JSON5 and JSONC need a second parser with different rules, and a path query language needs an expression evaluator. Both would make this page slower to load and harder to trust. It reads strict JSON, and tells you precisely which rule you crossed when the input is not strict.
My editor shows this file as valid — why does it fail here?
Most editors treat .json as JavaScript for highlighting, so a comment or a trailing comma looks fine. The parser that loads the file is stricter. Switch the output to Formatted, look at the line and column this page reports, and the difference is usually one of four things: a comment, a trailing comma, single quotes, or an unquoted key.