ElDevo
← All guides

How to Format JSON

A practical guide to formatting and validating JSON.

What formatting does

Formatting changes whitespace and indentation without changing the data represented by valid JSON. It makes nested objects and arrays easier to inspect.

Common JSON errors

Typical problems include trailing commas, missing quotation marks, unquoted property names, and mismatched braces or brackets. A formatter cannot reliably repair every invalid document, so validation is useful when parsing fails.

A practical workflow

Start with the smallest failing input, validate it, format it after it parses, then compare the resulting structure with the data your application expects.