Guides

How to read, format and fix JSON errors

JSON is the format that most websites and apps use to exchange data, and sooner or later you will have to open a file or API response and understand why it fails. Once you know the handful of rules, most errors become easy to spot.

What JSON looks like

JSON stores data as objects in curly braces, lists in square brackets and values that can be text, numbers, true, false or null. An object is a set of keys with values, and every key is text inside double quotes. A small example is a person with a name, an age and a list of languages.

It is designed to be readable by both people and programs, but when a system sends it on one long line, it becomes almost impossible for a person to read. That is where formatting helps.

The mistakes behind most errors

A trailing comma after the last item is the classic one: it is allowed in many programming languages, but not in JSON. Another frequent mistake is using single quotes, since JSON requires double quotes for text and keys. Missing quotes around a key, a missing comma between two items and unbalanced braces or brackets complete the list.

Comments are also not allowed in standard JSON. If a file has lines starting with two slashes, a parser will reject it. Special values such as undefined or NaN do not exist in JSON either.

Use the exact position of the error

A good validator tells you the line and column where parsing failed. Look slightly before that point, because the parser often notices the problem one step after it happened: a missing comma is reported at the start of the next item, not at the end of the previous one.

Fix one error at a time and validate again. Several messages at once usually come from a single early mistake.

Formatting and minifying

Beautifying adds line breaks and indentation so that you can follow the structure. Choose two spaces, four spaces or tabs according to your team convention. Minifying does the opposite and removes all unnecessary whitespace, which reduces size when you send data over a network or store it.

Sorting keys alphabetically helps when you compare two versions of the same file, since differences stand out instead of being hidden by a different order.

Keep your data private

JSON often contains customer records, tokens or internal configuration. Pasting it into a website that uploads it to a server is a risk you do not need to take. The Zipnify formatter runs entirely in your browser, so the content stays on your device. As a rule, remove real secrets from anything you share for help.

Numbers, dates and large values

JSON has no date type, so dates are stored as text, commonly in the ISO format with year, month and day. Very large integers can lose precision in some programs that read all numbers as floating point, so identifiers that matter are safer as text.

Try the tool: JSON formatter and validator

Frequently asked questions

Why is my JSON invalid?

The most common causes are a trailing comma, single quotes, a missing comma between items, unquoted keys or comments. The error line and column help you find it.

Can JSON have comments?

Not in standard JSON. Remove them, or use a format designed for configuration with comments.

What is the difference between format and minify?

Format makes the JSON readable with indentation. Minify removes whitespace to make it smaller.

Is it safe to paste JSON into an online formatter?

Only if the tool works locally. Zipnify processes it in your browser and does not upload it.

More guides