JSON Formatter

Format and validate JSON data

Runs in your browser

Formatted JSON will appear here...

JSON is a text format for structured data, defined by RFC 8259 and ECMA-404: objects in curly braces, arrays in square brackets, double-quoted strings, numbers, true, false and null. This formatter checks your input with the browser's built-in JSON parser, so only strictly valid JSON passes, and it reports the line and column of the first syntax error. It re-indents with 2, 4 or 8 spaces, minifies by removing all whitespace outside strings, and shows a collapsible tree. Nothing is uploaded.

Use cases

  • Pretty-print a minified API response so you can read it or paste it into a bug report
  • Find the exact line and column of a trailing comma or a missing quote before a config file breaks a deploy
  • Minify JSON for a request body, a test fixture or an environment variable
  • Open only the branch you need in a deeply nested response with the collapsible tree view

When to use?

Use it whenever you need to read, check or shrink JSON. It accepts strict JSON only, so JSON5, JavaScript objects with unquoted keys, and files with comments are reported as invalid. To send JSON inside a URL query parameter, format or minify it here and then encode it with URL Encoder.

Examples

  1. Format minified JSON from an API

    Input

    {"name":"GetIt","tools":16,"tags":["free","no signup"]}

    Output

    { "name": "GetIt", "tools": 16, "tags": [ "free", "no signup" ] }

  2. Minify JSON before sending it

    Input

    { "id": 42, "active": true }

    Output

    {"id":42,"active":true}

Questions and answers

Why is my JSON invalid?

The most common causes are a comma after the last item, single quotes instead of double quotes, and comments. Standard JSON allows none of these.

Can I change the indentation?

Yes. Choose 2, 4 or 8 spaces and the output is formatted again immediately.

What is the tree view?

Tree view shows your JSON as a collapsible outline, so you can open only the parts you need. Raw view shows the formatted text, ready to copy.

Why did a long number change after formatting?

Browsers store JSON numbers as 64-bit floating point values, which are exact only up to 9,007,199,254,740,991 (2^53 − 1). Larger integers, such as some database IDs, get rounded. RFC 8259 warns about this, so send large IDs as strings.

What happens if a key appears twice in an object?

The last value wins and the earlier one is dropped from the output. RFC 8259 says object names should be unique, because other parsers may keep the first value or reject the object.

Sources and standards

All Tools