🛠️ FileTools.studio
All Tools Guides About Contact
Home/Guides/Understanding JSON (and How to Fix Common Errors)

Understanding JSON (and How to Fix Common Errors)

June 22, 2026 · 6 min read

JSON is everywhere — APIs, config files, databases. It’s simple once you know the rules, and most "invalid JSON" errors come down to a handful of easy-to-fix mistakes.

Learn JSON in 10 Minutes — Web Dev Simplified ▶ Learn JSON in 10 Minutes — Web Dev Simplified — opens YouTube on click

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and exchanging data. It’s human-readable and used by virtually every web API. A JSON document is built from two structures: objects (key–value pairs in curly braces) and arrays (ordered lists in square brackets).

The rules of valid JSON

  • Data is written as "key": value pairs.
  • Keys must be double-quoted strings.
  • Values can be a string, number, boolean (true/false), null, an object, or an array.
  • Strings use double quotes, never single quotes.
  • Items are separated by commas — with no trailing comma after the last one.

A small valid example:

{ "name": "Ada", "age": 36, "skills": ["math", "code"], "active": true }

The most common JSON errors

  • Trailing comma — a comma after the final item, like [1, 2, 3,]. Remove it.
  • Single quotes — 'key' instead of "key". JSON requires double quotes.
  • Unquoted keys — { name: "Ada" } is valid JavaScript but invalid JSON; keys need quotes.
  • Missing or extra comma between items.
  • Comments — JSON doesn’t support // or /* */ comments.
  • Unescaped characters — quotes or backslashes inside strings must be escaped with a backslash.

How to validate and fix JSON fast

Rather than hunting for a stray comma by eye, paste your JSON into our JSON Formatter. It validates the JSON and, if something’s wrong, tells you exactly where the problem is. Once it’s valid, click Beautify to indent it for readability or Minify to compact it for sending over the wire. It all runs in your browser, so your data never leaves your device.

Beautify vs. minify

Beautified JSON has indentation and line breaks, which makes it easy to read and debug. Minified JSON strips every unnecessary space to make the smallest possible payload — useful for APIs and storage. They contain identical data; only the whitespace differs.

A tip for working with APIs

When an API call fails, copy the raw response into the formatter first. Seeing it indented often makes the problem obvious — a missing field, an unexpected null, or an error message buried in the structure.

Frequently asked questions

Why is my JSON invalid?

The most common causes are a trailing comma after the last item, single quotes instead of double quotes, unquoted keys, or comments — which JSON does not allow. A validator will point to the exact spot.

Can JSON have comments?

No. Standard JSON does not support comments. Some tools accept "JSON with comments" (JSONC), but strict JSON parsers will reject them.

What’s the difference between beautify and minify?

Beautify adds indentation for readability; minify removes all unnecessary whitespace for the smallest size. The underlying data is identical.

Tools used in this guide

🧩JSON Formatter 🔁Base64 Encode / Decode
FileTools.studio

🔒 Private by design. Every tool runs entirely in your browser — your files are never uploaded.

Image
Image Converter Image Compressor Image Resizer
PDF
Merge PDF Split PDF
Text
Word Counter Case Converter
Generators
Lorem Ipsum Generator Password Generator QR Code Generator
Developer
JSON Formatter Base64 Encode / Decode
Calculators
Percentage Calculator Loan Calculator Interest Calculator
Guides About Contact Privacy Policy Terms of Use
© 2026 FileTools.studio — no uploads, no tracking, no nonsense.