What does a JSON formatter do?
JSON is the text format that most websites, apps and APIs use to send data to each other. A computer is happy with one long line, a person is not. A formatter puts every value on its own line and indents it, so you can see what sits inside what. Minify does the opposite: it removes every space and line break that is not needed, which makes the text smaller to send or to store. In both cases the data itself does not change.
Why does it say my JSON is not valid?
JSON is stricter than it looks. These mistakes cause most of the errors:
- a comma after the last item, as in
{"a": 1,} - single quotes instead of double quotes
- a property name without quotes, as in
{name: "x"} - a comment, which JSON does not allow
- a missing comma between two items
- a line break inside a text (write
\ninstead)
The message gives the line and the column, and shows that line with a mark under the problem. For the first four the tool does not stop. It shows a corrected version in the output and tells you what it changed. A Python True, False or None is fixed the same way.
Will it change my numbers or my text?
No. Many formatters read the JSON and write it out again, and on the way they turn 12345678901234567890 into 12345678901234567000, or 1.0 into 1. This one only moves the spaces and line breaks. Numbers, text and \u00e9-style escapes stay exactly as you wrote them, and so does the order of the keys, unless you turn on Sort keys.
What does Sort keys do?
It puts the keys in A to Z order inside every object, however deep. Lists keep their order, because the order of a list means something. Sorting helps when you want to compare two versions of the same file: once both have sorted keys, every difference you see is a real one.
Which indent should I use?
Two spaces is what most JavaScript and web projects use. Four spaces is common in Python and Java. A tab lets each person set the width in their own editor. The choice changes how the text looks and nothing else.
What if the same key appears twice?
JSON does not forbid it, but most programs keep only the last value and silently drop the first. The tool shows a note when it finds a repeated key, because that is usually a copy and paste mistake.
Is my JSON sent anywhere?
No. Everything happens in your browser. That matters when the JSON holds a token, an email address or customer data.