JSON Formatter

Format, validate and beautify JSON data

Free
Input JSON
Output
Formatted JSON will appear here...

How to use this tool

Paste JSON, press Format to pretty-print and validate it, or Minify to compress it. Parsing happens in your browser, so private payloads stay private.

  1. Paste your JSON

    Put the JSON — an API response, a config file, a log line — into Input JSON.

  2. Click Format to validate and indent

    Format parses the text and re-prints it with two-space indentation. If it parses, the JSON is valid.

  3. Or click Minify to compress

    Minify removes all unnecessary whitespace so the document is on a single line — useful before embedding JSON in a URL, header or test fixture.

  4. Fix any error it reports

    When the JSON is invalid you get the parser's own message, which usually names the unexpected character and its position. The usual culprits are trailing commas, single quotes, unquoted keys and comments — see how to fix "Unexpected token" errors.

  5. Explore and copy the result

    The output is shown as a collapsible tree so you can fold large objects. Use Copy to take the formatted text, or Clear to start again.

Good to know: Strict JSON allows only double-quoted strings and no trailing commas. JavaScript object literals that look similar are often not valid JSON.

Validation and pretty-printing, explained properly

A JSON formatter is a parser front-end: it reads your text with a strict JSON parser, rejects it with a position-tagged error if the syntax is invalid, and re-serialises the parsed structure with consistent indentation.

The useful part of a JSON formatter is not the indentation — it is the parse step in front of it. When an API returns 400, when a CI job fails on a config file, or when a webhook payload silently drops a field, the question is almost always whether the document is valid JSON and, if not, exactly which character broke it.

This page covers what the parser accepts and rejects, the four syntax errors that account for most failures, how beautifying and minifying differ mechanically, and when a browser tool is the wrong choice.

What each button does under the hood

Both actions run the same parse first. If the parse fails, nothing is produced — that is the validation.

Format
Parses the text, then re-serialises it with two-space indentation. Because it round-trips through a parser, the output is guaranteed to be valid JSON. Keys keep the order you wrote them in, with one JavaScript quirk: whole-number keys such as "1" or "42" are always listed first, in ascending order.
Minify
Parses the text and re-serialises with no whitespace at all. Typical saving on an indented API response is 15–30% of the byte count before any compression.
The tree view
Valid output renders as a collapsible tree with values coloured by type — strings, numbers, booleans and null are visually distinct — so a number that arrived as a quoted string is obvious at a glance.
Error reporting
The message comes from your browser’s own JSON parser and includes a character position. Wording differs between Chrome, Firefox and Safari; the position number is the part to trust.
Where it runs
Entirely in your browser. Payloads are never uploaded, which matters when a response body contains customer data or a bearer token.
What is not valid JSON
Comments, trailing commas, single-quoted strings, unquoted keys, NaN, Infinity and undefined. Several of those are legal JavaScript, which is why they slip in so often.

The four failures that cause most invalid JSON

Each example below is a real rejection. Read the position number, look at that character, and fix the first error only — later errors usually disappear with it.

Example 1: Trailing comma

Input
{"name": "Ada", "role": "engineer",}
Parser says
Expected double-quoted property name
in JSON at position 35

Position 35 is the closing brace. After a comma the parser requires another key, so it reports the brace, not the comma. JavaScript object literals allow the trailing comma; JSON never has.

Example 2: Single quotes

Input
{'name': 'Ada'}
Parser says
Expected property name or '}'
in JSON at position 1

JSON strings must use double quotes, for keys and values alike. This is the classic symptom of pasting a Python dict or a JavaScript literal and expecting it to parse.

Example 3: Comments in a config file

Input
{
  "port": 8080, // dev only
  "debug": true
}
Parser says
Unexpected token '/'
… is not valid JSON

Standard JSON has no comment syntax. Tools such as VS Code accept JSONC in their own settings files, but a strict parser — including this one and most server-side libraries — will not.

Example 4: A number that is really a string

Input
{"total": "1200", "count": 3}
Parses fine — but look at the tree
{
  "total": "1200",   ← string
  "count": 3         ← number
}

This is valid JSON, so validation cannot help you. The colour-coded tree is how you catch it: a quoted "1200" will fail arithmetic downstream. Type mismatches cause more production bugs than syntax errors do.

Behaviour that surprises people

Duplicate keys are silently resolved

JSON.parse keeps the last occurrence of a repeated key, so {"a":1,"a":2} becomes {"a":2} with no warning. If your formatted output is missing a field you definitely pasted, look for a duplicate key above it.

Very large integers lose precision

JSON numbers are parsed as IEEE-754 doubles. An ID above 2^53 − 1 (9,007,199,254,740,991) will round — a real problem with Twitter-style snowflake IDs and some ledger systems. Transmit those as strings.

Key order is preserved, not sorted

Formatting re-serialises in insertion order. It will not normalise two payloads for diffing; use a dedicated JSON diff or sort keys in code if you need stable comparison.

Minify before you compress, not instead

Gzip and Brotli already collapse repeated whitespace efficiently. Minifying a response that is compressed in transit saves far less than the raw byte count suggests — it matters most for storage, log lines and URL-embedded payloads.

Secrets in pasted payloads

Nothing is uploaded, but screenshots are. Strip Authorization headers, API keys and personal data before sharing a formatted payload in a ticket. Need to inspect an encoded token first? Decode it with the Base64 encoder and decoder.

Browser formatter vs. jq, your IDE, and a browser extension

Direct answer: use a browser formatter for a one-off payload you already have in your clipboard, and a command-line tool the moment you need to filter, transform or script.

OptionBest forTrade-off
This browser formatterA payload pasted from DevTools, a log line or a support ticketNo querying or transformation, and no file handling — it is a read-and-fix surface, not a pipeline stage.
jq on the command lineFiltering, reshaping and scripting over files or streamsA real query language to learn, and it is another dependency on a locked-down machine.
IDE formatting (VS Code, JetBrains)JSON that lives in your repositoryFormats on save with your project settings, but you have to get the payload into a file first.
Browser JSON-viewer extensionReading API responses directly in a browser tabOnly helps for URLs you can open in a browser — no help with a POST body or a payload from a log.

Working with tabular source data instead? Convert it first with the CSV to JSON converter, then format the result here.

A repeatable way to debug a rejected payload

  • Fix the first reported error only, then re-run — cascading errors are usually one missing bracket.
  • Compare the position number against the raw text, not the pretty-printed version, since indentation shifts offsets.
  • If the document is truncated, check whether the source was cut by a log line-length limit before blaming the API.
  • Confirm value types in the tree view: quoted numbers and "true" as a string are frequent culprits.
  • For a schedule or automation payload, sanity-check the cron field with the cron expression parser.
  • Need to pull specific values out of a large document? Prototype the pattern in the regex tester before writing the parsing code.

Sources and further reading

Where the technical statements on this page come from: standards, specifications and the official documentation of the tools and services involved.

How this page is maintained

Error messages shown here were reproduced with the browser JSON parser this tool uses, and the two-space indentation and tree-view behaviour were read from the tool’s source. Parser wording varies by browser engine, which the page states rather than glossing over.

Written and reviewed by the ToolsRacks editorial team. Last reviewed: . Found an error? Tell us — see our editorial standards.

Works great with these tools

Pull IDs or tokens out of logs before formatting JSON — prototype extraction patterns with our free regex tester and playground.

Turning API docs or README snippets into HTML? Convert Markdown to sanitized HTML with our free Markdown to HTML converter.

Have data in a spreadsheet? Convert it to JSON format first with our free CSV to JSON converter, then beautify it here.

API responses sometimes contain Base64-encoded values inside JSON. Decode them instantly with our Base64 encoder and decoder.

Debugging an API or webhook? Check the DNS records of the server domain using our free DNS checker.

Frequently asked questions

Answers to the questions people ask most often about JSON Formatter.

What does formatting JSON actually do?

Your text is parsed with a strict JSON parser and then re-serialised with two-space indentation. Because it round-trips through a parser, formatted output is guaranteed to be valid JSON.

Why does my JSON fail validation?

The four usual causes are a trailing comma before a closing brace or bracket, single quotes instead of double quotes, comments, and unquoted keys. All four are legal JavaScript and none are legal JSON.

What does the position number in the error mean?

It is the character offset where the parser gave up. Fix the first reported error and re-run, because later errors usually cascade from one missing bracket. The exact message wording differs between browsers.

Is my JSON uploaded to a server?

No. Parsing and formatting run entirely in your browser, so payloads containing tokens or customer data never leave your device.

Why did a duplicate key disappear from my output?

JSON parsers keep the last occurrence of a repeated key without warning, so a document containing the same key twice loses the first value. If a field you pasted is missing, look for a duplicate key above it.

When should I minify instead of beautify?

Minify for storage, log lines and URL-embedded payloads. Over the wire it matters less than people expect, because gzip and Brotli already collapse repeated whitespace efficiently.

Why did my large ID number change?

JSON numbers are parsed as IEEE-754 doubles, so integers above 9,007,199,254,740,991 lose precision. Transmit large identifiers as strings instead.

Guides for the JSON Formatter

Troubleshooting and background reading written for people who use this tool.

Picked from Developer Tools and adjacent categories. Each one has its own page explaining how it works and where it falls short.

Looking for something else? See every tool in Developer Tools → · Browse all 32 free tools →