Formula Guide

    How to Format and Validate JSON

    JSON (JavaScript Object Notation) is the standard data interchange format for APIs, configuration files, and web services. It is easy for humans to read and write, and easy for machines to parse. Formatting (pretty-printing) adds indentation and line breaks to make nested JSON readable; minifying removes whitespace to reduce file size. Valid JSON follows strict syntax rules — a single missing comma or unquoted key will break parsing.

    Last updated: March 31, 2026

    The Formula

    JSON Structure Rules:
    • Strings must use double quotes (not single quotes)
    • Keys must be quoted strings
    • Values: string, number, boolean, null, object {}, or array []
    • No trailing commas after the last item
    • No comments allowed
    • Top-level must be an object {} or array []
    Common JSON content types: application/json. Always validate JSON from external sources before parsing — malformed JSON will throw a parse error in any language.

    Variable Definitions

    SymbolNameDescription
    {}ObjectAn unordered collection of key-value pairs, e.g. {"name": "Alice", "age": 30}
    []ArrayAn ordered list of values, e.g. [1, 2, 3] or [{"id": 1}, {"id": 2}]
    nullNullRepresents an intentionally absent value — written as the literal null (not a string)

    Step-by-Step Example

    The following minified JSON has an error. Identify it, fix it, and format it.

    Given

    Invalid JSON:{name: 'Alice', age: 30, active: true,}

    Solution

    1. 1
      Error 1: keys must be quoted strings: name → "name", age → "age", active → "active"
    2. 2
      Error 2: strings must use double quotes: 'Alice' → "Alice"
    3. 3
      Error 3: trailing comma after last value: true, → true (remove the comma)
    4. 4
      Format with indentation: { "name": "Alice", "age": 30, "active": true }

    Valid formatted JSON: {"name": "Alice", "age": 30, "active": true}

    Ready to calculate?

    Use the free JSON Formatter — instant results, no sign-up.

    Open Calculator

    Common Mistakes to Avoid

    Using single quotes — JSON requires double quotes for all strings and keys.

    Trailing commas after the last item — valid in JavaScript but illegal in JSON.

    Adding comments — JSON has no comment syntax. Use a separate documentation field or a .jsonc parser for config files.

    Using undefined or NaN — these JavaScript values do not exist in JSON. Use null instead.

    Frequently Asked Questions

    Related Guides