Skip to content
FindTool

    JSON Formatter

    Pretty-print, validate and minify JSON with syntax highlighting and precise error locations.

    JSON Formatter tool

    Result
        

    What this tool does

    Paste JSON and this formatter re-indents it into something readable, tells you immediately whether it is valid, and — when it is not — points at the exact line and explains the problem in plain language rather than repeating your browser's error message.

    It also minifies, sorts keys, shows a collapsible tree, and reports the document's size, key count and nesting depth. Everything runs in this tab, so it is safe to paste a production API response.

    Common uses

    • Making a single-line API response readable — log output and curl results almost never arrive formatted.
    • Finding why a config file is rejected. The error location matters more than the error text, and a 4,000-character single line hides it completely.
    • Sorting keys on two versions of a response so a diff shows real changes instead of reordered fields.
    • Minifying before embedding JSON in an environment variable or a URL parameter.

    A short example

    This input:

    {"user":{"id":7,"roles":["admin","editor"],"active":true}}

    becomes:

    {
      "user": {
        "id": 7,
        "roles": [
          "admin",
          "editor"
        ],
        "active": true
      }
    }

    Mistakes that break JSON

    Four problems account for most invalid documents, and all four are things that would be perfectly legal in a JavaScript object literal:

    • Trailing commas. {"a": 1,} is valid JavaScript and invalid JSON.
    • Single quotes. JSON requires double quotes around both keys and string values.
    • Unquoted keys. {a: 1} needs to be {"a": 1}.
    • Raw newlines inside strings. They must be escaped as \n.

    Comments are also invalid. If your config file has them, it is JSON5 or JSONC, not JSON — strip them before parsing with a standard parser.

    Worth knowing

    Formatting never changes your data, only whitespace. Key order is preserved unless you ask for sorting. One caveat applies to very large integers: JavaScript numbers lose precision above 253, so an ID like 9007199254740993 can come back altered. If your payload contains IDs that long, treat them as strings.

    Frequently asked questions

    Why does my JSON fail to parse when it looks correct?

    The three most common causes are trailing commas after the last element, single quotes instead of double quotes around keys and strings, and unescaped newlines inside string values. JSON is stricter than JavaScript object literals — none of those are legal.

    Does formatting change my data?

    No. Formatting only changes whitespace. Key order is preserved, and numeric values are re-serialised exactly as parsed, so nothing is rounded or reordered.

    Is there a size limit?

    Documents up to roughly 2 MB format instantly. Larger inputs still work but syntax highlighting is disabled above 300 KB to keep the page responsive.