Formatting versus validation
Formatting changes whitespace and indentation; validation determines whether input follows JSON grammar. A formatter usually parses first, so malformed input cannot be safely reformatted until the syntax error is corrected.
JSON supports objects, arrays, strings, numbers, booleans, and null. It does not support comments, trailing commas, single-quoted strings, undefined, or unquoted property names.
Common errors
Trailing commas are frequent when data is copied from JavaScript. Unescaped line breaks and quotation marks can terminate strings unexpectedly. Duplicate keys may parse but remain risky because consumers can disagree about which value wins.
When an error includes a character position, inspect a small region around it. The real cause may appear slightly earlier, especially with a missing quote or bracket.
Protect sensitive input
Logs, API responses, and configuration files may contain tokens, customer identifiers, or internal URLs. Prefer a browser-local tool and still redact secrets before sharing formatted output. Local processing reduces transmission risk; it does not make copied data safe to publish.
Make validation repeatable
Interactive validation is useful during investigation. For maintained projects, add schema validation and automated tests so required fields, types, and constraints are checked consistently in development and CI.
Turn the concepts in this guide into a practical estimate with DevCalc’s free browser-based tools.
Open related tools →