What JSON Actually Is
JSON stands for JavaScript Object Notation. It is a text format for representing structured data — objects, arrays, strings, numbers, booleans, and null values — in a way that is easy for both humans and machines to read.
It became the standard data format for web APIs because it is simpler than XML, readable without special tools, and natively understood by JavaScript. Today it is used everywhere: REST APIs, config files, databases, log files, browser storage, and more.
A valid JSON document is either an object ({...}) or an array ([...]). Everything inside follows strict syntax rules. Unlike JavaScript itself, JSON does not allow trailing commas, single quotes, or comments. These rules are what trip people up most often.
The Most Common JSON Errors
Trailing comma — This is the number one mistake. In JavaScript you can write { "name": "Alice", } but in JSON, that trailing comma after the last item is a syntax error.
Single quotes — JSON requires double quotes for strings. { 'name': 'Alice' } is invalid. { "name": "Alice" } is correct.
Unquoted keys — JavaScript allows { name: "Alice" } but JSON does not. Keys must always be quoted strings.
Comments — JSON does not support comments at all. // this is a comment will break your JSON completely.
Unclosed brackets — One missing } or ] somewhere deep in a large JSON structure will make the whole thing invalid.
Incorrect nesting — Opening with { and closing with ] (or vice versa) causes parse errors that can be hard to spot in long files.
How to Read a JSON Error Message
JSON parsers typically tell you the line and column where they gave up — but they report the position where they detected the failure, not necessarily where the actual mistake is.
For example: SyntaxError: Unexpected token '}' at position 234 usually means the parser found a closing brace where it did not expect one — which often means you are missing an opening brace or have an extra comma somewhere earlier in the file.
The best approach: paste the broken JSON into a formatter. Good formatters not only show you where the error is but also highlight the surrounding context, making it much easier to spot what is wrong.
Why Formatting Matters Beyond Readability
Minified JSON (all on one line, no spaces) is smaller — useful for network transfer. But for humans working with it, readable formatting with indentation is essential.
Indented JSON lets you see the nesting structure at a glance. You can immediately see that a key belongs to an inner object rather than the outer one. You can count brackets. You can spot when an array has fewer items than expected.
Well-formatted JSON also makes version control diffs much cleaner. When minified JSON changes, a diff might show one enormous line changed. When formatted JSON changes, the diff shows exactly which key or value was modified.
Formatting JSON Instantly
Our JSON Formatter tool takes any JSON — even messy, minified, or partially broken — and reformats it with proper indentation. It validates as you type, highlights errors with the exact position, and lets you choose 2-space or 4-space indentation.
Paste your JSON, see it cleaned up in seconds, copy the result. If there are errors, the tool tells you exactly where and what went wrong so you can fix them without guessing.
Related Topics
Try it yourself
JSON Formatter
Everything in this article is available in the free tool. No account, no subscription, no install.
Open JSON Formatter →