Skip to content
SocialTools

JSON Formatter

Paste JSON to get it indented with two spaces, or see the parser error that explains why it will not load.

What it does

The formatter runs your input through the browser's own JSON parser and prints the result with two-space indentation. If the text is not valid JSON, you get the parser's error message instead, which usually names the unexpected character and its position.

Use it when an API returns one long line, when a JSON-LD block breaks your structured data, or when a config file refuses to load and you need to find the stray comma or missing quote. The check reruns on every keystroke, so you can fix and confirm in the same box.

How to use it

  1. 1

    Paste your JSON into the JSON input box.

  2. 2

    If a red error message appears, fix the reported problem in the input and it re-checks immediately.

  3. 3

    Read the Formatted JSON panel once the input is valid.

  4. 4

    Click Copy formatted to copy the indented result, or click Minify to get the same JSON on one line with all whitespace removed, then Copy minified.

What you get

Valid JSON re-printed with two-space indentation, or on a single line after you click Minify, keys in their original order. Invalid input shows the browser parser's error message and no output.

When to use it

Read one-line API responses
Paste a minified response from your network tab and get nested objects and arrays laid out on separate indented lines.
Debug JSON-LD schema
Check the script contents of a schema block before adding it to a page. A syntax error here stops search engines from reading any of it.
Find the broken character
When a file fails to parse, the red error line shows the message from the parser, such as an unexpected token or end of input.
Tidy files before committing
Standardise a hand-edited package.json or settings file to two-space indentation before a code review.
Shrink JSON for a request body
Click Minify to strip indentation and line breaks so the JSON fits in a single-line environment variable, curl command or query parameter.

Example

Input

[{"name":"Alice","email":"alice@example.com","role":"admin"}]

Output

[
  {
    "name": "Alice",
    "email": "alice@example.com",
    "role": "admin"
  }
]

The data is unchanged; only whitespace is added.

Tips

  • The parser is strict JSON: trailing commas, comments, single-quoted strings and unquoted keys all fail. JavaScript object literals copied from code often need these fixed first.
  • Numbers larger than 9007199254740991 lose precision when parsed, so long numeric IDs (common in social platform APIs) can change in the output. Keep such IDs as strings.
  • If a key appears twice in the same object, only the last value survives formatting. Use this to spot accidental duplicates in hand-written config.
  • Paste only the JSON itself. For JSON-LD, copy what is inside the script tags, not the tags.

Questions

Why does my JSON fail with "Unexpected token"?

The parser hit a character that is not allowed at that point. The usual causes are a trailing comma after the last item, single quotes instead of double quotes, a comment, or a missing comma between two properties.

Will formatting change the values in my JSON?

Strings, booleans and nesting stay the same. The exceptions come from JSON parsing itself: very large integers are rounded, and duplicate keys collapse to the last value.

Can I format JSON Lines or NDJSON here?

Not as a whole file. JSON Lines holds one JSON value per line, which is not a single valid JSON document. Paste one line at a time, or wrap the lines in [ ] with commas between them.

How do I check JSON-LD structured data syntax?

Paste the contents of the script type="application/ld+json" block. If it formats cleanly, the syntax is valid. Checking whether the schema types and properties are correct is a separate step for the Schema Validator.