JSON formatting: frequently asked questions

Last updated 2026-11-29

Direct answers to the questions that appear whenever a JSON document formats but still behaves unexpectedly.

At a glance

TopicWhat the tool does
Indentationtwo spaces, fixed
Numeric-looking keyssorted ascending, before other keys
Duplicate keyslast value kept, no warning
Integers above 2^53rounded to the nearest double
Values above the double rangebecome null in the output
Whitespace and newlinesremoved on minify, normalised on format

Everything below follows from one design decision: the tool parses the text into JavaScript values and serialises them again. It is a data viewer, not a text editor, so it cannot preserve layout, number spelling or duplicate members.

A quick way to test any suspicion: paste the smallest document that shows the problem, format it, and compare field by field with the original. If the output is valid but a value changed, the cause is type mapping rather than syntax; if the output is empty and the message starts with Parse failed, the cause is syntax and the position in the message is the best clue.

Frequently asked questions

Why are there exactly two spaces of indentation?

Because the formatter calls JSON.stringify(value, null, 2). The indent is fixed and cannot be changed to a tab or four spaces in this tool; reformat with your editor afterwards if your project uses another style.

Why did my keys get reordered?

Keys that look like array indexes, such as 0, 1, 2 and 10, are always emitted first in ascending numeric order. Other keys keep their insertion order after them, so 2, 10, 1, name becomes 1, 2, 10, name.

Does the tool detect duplicate keys?

No. JSON.parse keeps only the last value, so by the time the formatter runs the earlier values are gone. A document with three copies of the same key formats cleanly with no warning.

Why did a 19-digit ID lose its last digits?

Integers are stored as doubles and only stay exact up to 9007199254740991. 12345678901234567890 comes back as 12345678901234567000. Send such IDs as quoted strings to keep every digit.

My number 1e400 turned into null. Why?

It parses as Infinity, which is outside the JSON number range. Serialising Infinity produces null, so the overflow is replaced silently instead of raising an error. Check magnitude ranges in a separate validation step.

Can I format JSON with comments or trailing commas?

Not with this tool. Both are syntax errors for JSON.parse. Strip comments and trailing commas first, or use a JSON5 parser if your source really needs them.

Why does a file saved on Windows fail on the first character?

It probably starts with a byte-order mark, which is not JSON whitespace. Save as UTF-8 without BOM, or remove the leading three bytes, and the same content will parse.

Is minified output smaller in a meaningful way?

It removes indentation, line breaks and spaces only. Keys, strings and values are untouched, so the saving equals the size of the pretty layout, which is a large share of a deeply nested document and almost nothing for a short flat object.

Does formatting change Chinese or emoji?

It decodes escapes and prints the real characters, so a document full of backslash-u sequences becomes readable Chinese or emoji. The data is identical; only the representation changes.

Is my JSON uploaded to a server?

No. Parsing, formatting, minifying and copying run in the page, and the base64 and URL encoding tools on this site work the same way. Nothing is sent, so internal configuration stays local.

Open the JSON Formatter

Keep reading