ToolJoltTools
Developers

How to Format and Validate JSON (and Fix Common Errors)

A single misplaced comma can break an entire API response. Knowing JSON's handful of strict rules saves hours of debugging.

By ToolJolt Team ยท April 30, 2026

JSON's strict rules

  • Keys must be in double quotes โ€” single quotes are invalid.
  • No trailing commas after the last item.
  • Strings use double quotes; values can be string, number, boolean, null, object or array.
  • No comments are allowed in standard JSON.

The errors that bite most

The classics are a trailing comma, a missing comma between items, single quotes copied from code, and unescaped characters inside strings (like a raw newline or quote). Validators point to the exact line, which turns a frustrating hunt into a two-second fix.

Why formatting helps

Minified JSON is one long line โ€” impossible to read. 'Pretty-printing' it with indentation reveals the structure, makes nesting obvious, and exposes where a bracket is missing. Formatting and validating usually go hand in hand.

Minify for production

Once it is correct, you often want the opposite: minified JSON with no whitespace, to save bytes over the wire. The same tools that pretty-print can compact it again.

Format and validate instantly

ToolJolt's JSON formatter pretty-prints, validates and minifies JSON in your browser โ€” your data stays local, and errors are flagged as you paste.

Free tools mentioned in this guide

Frequently asked questions

Why is my JSON invalid?

Most often a trailing comma, a missing comma, single quotes instead of double, or an unescaped character in a string. A validator will point to the exact spot.

Can JSON have comments?

No, standard JSON does not allow comments. If you see them, it is a non-standard variant like JSONC used in some config files.

What does formatting JSON do?

It adds indentation and line breaks so the structure is readable. Minifying does the reverse to save space.

More from the blog

Sponsored