Guide

How to Format, Validate and Read JSON

Learn what JSON is, how formatting and validation help, and how to fix common JSON errors.

A JSON formatter takes raw, often minified JSON and re-indents it with consistent spacing so the structure is readable. A validator checks the syntax and reports the exact location of errors. Both are everyday tools for anyone working with APIs or config files.

What JSON is

JSON (JavaScript Object Notation) is a lightweight text format for storing and transporting structured data. It uses objects (key-value pairs in curly braces), arrays (ordered lists in square brackets), and a handful of value types: strings, numbers, booleans, null, objects, and arrays. It has become the default data format for web APIs.

Why formatting and validation matter

Minified JSON (no whitespace) saves bytes but is unreadable. Formatting restores the indentation so you can see nesting at a glance. Validation catches a missing comma, an unquoted key, or a trailing comma — errors that break parsing and are hard to spot in a wall of minified text.

Common JSON errors and how to fix them

  • Trailing comma before a closing brace or bracket — remove it.
  • Unquoted keys — JSON requires double-quoted strings for keys.
  • Single quotes instead of double quotes — JSON only allows double quotes.
  • Comments — JSON has no comments; remove them or use JSONC.
  • A missing comma between items — add it where the parser points.

How to use a JSON formatter

  1. Paste raw JSON into the formatter.
  2. Choose an indent size (2 spaces is common).
  3. Read the formatted output and any error messages.
  4. Fix errors and re-format until it validates.

When a JSON formatter is useful

  • Inspecting API responses and request bodies.
  • Editing config files written in JSON.
  • Debugging a parse error in a data file.
  • Minifying JSON before deploying to save bytes.

Put it into practice

Use the JSON Formatter & Validator right now — free, in your browser, no sign-up required.

Try the JSON Formatter & Validator