Skip to content

JSON Formatter and Validator

Paste messy or minified JSON and get clean, indented output with syntax colors. The validator checks your JSON as you type and points to the line and column of the first error.

Drop your JSON here

Paste JSON, upload a .json file, or drop text here to format and validate instantly.

.json files, read in your browser

Formatter Controls

Waiting for JSON
Ready. Paste JSON to begin.

Input & Formatted Output

No errors Line 1, Col 1

Raw JSON Input

Editable 0 chars
1
Live parse on No parse attempt yet
No file loaded

Formatted Output

Syntax highlighted 0 chars
1
No formatted output yet 0 matches
Ready to download

JSON Structure Tree

Validated JSON will appear here as an expandable tree.

Runs in your browser. Nothing you type, paste or open here is uploaded.

To format JSON, paste it into the Raw JSON Input box or select a .json file, then select Pretty Print. The formatter parses the text with your browser's JSON parser and re-indents it with 2 spaces by default, coloring keys, strings and numbers. If the JSON is invalid, it shows the line and column where parsing failed.

How to format JSON online

  1. Add your JSON. Paste it into Raw JSON Input, drop a .json file on the upload box, or choose Select JSON File. Load Sample fills in a small test object if you just want to try it.
  2. Choose the layout. Set Indentation to 2 spaces, 4 spaces or Tab. Set Object Keys to Sort keys A → Z if you want keys in alphabetical order at every level.
  3. Format or minify. Select Pretty Print (Ctrl+Enter) for readable output or Minify JSON for one line. Validate only checks the syntax.
  4. Use the result. Select Copy Output, or Download JSON to save a .json file named after the file you loaded. Output → Input moves the result back for another pass.

What does a JSON formatter do?

A JSON formatter (also called a JSON beautifier) parses your text into data and writes it back out with consistent indentation and one value per line. Nothing about the data changes: only the whitespace between tokens does. In JavaScript the basic job is one line, JSON.stringify(JSON.parse(text), null, 2). This page checks your text with JSON.parse but rebuilds the output from the text you pasted, so every number keeps its exact digits, and it adds syntax coloring, line numbers and a search box.

Here is a 55-character minified object:

{"user":{"id":7,"tags":["admin","beta"]},"active":true}

After Pretty Print with 2-space indentation it becomes:

{
  "user": {
    "id": 7,
    "tags": [
      "admin",
      "beta"
    ]
  },
  "active": true
}

The JSON Structure Tree under the editors shows the same data as collapsible objects and arrays, with counts such as Array(2). Use Expand All to open every level of a deeply nested API response at once.

How the JSON validator finds errors

The validator uses the browser's strict parser, which follows the JSON standard (RFC 8259). With Live Validation set to On while typing, it re-checks the input a fraction of a second after you stop typing. Smart debounce waits a little longer, which helps with large files, and Manual only waits for you to select Validate. When parsing fails, the status changes to Invalid JSON, the error badge shows the line and column, and that line number is highlighted in the gutter.

Most errors come from writing JavaScript object syntax instead of JSON:

MistakeInvalidValid JSON
Trailing comma{"a": 1,}{"a": 1}
Single quotes{'a': 'x'}{"a": "x"}
Unquoted key{a: 1}{"a": 1}
Comment{"a": 1 // id}{"a": 1}
Non-JSON value{"a": undefined}{"a": null}

The exact error text depends on your browser. Chrome usually reports "Unexpected token", while Firefox says "JSON.parse: expected double-quoted property name" or similar. The tool doesn't repair invalid JSON for you; it tells you where to look.

JSON pretty print vs minify: when to use each

Pretty print JSON when people will read it: config files, API responses you're debugging, fixtures in a code review. Indented JSON also produces cleaner line-by-line diffs. Minify JSON when a machine is the reader, such as a request body or a value stored in a database column. In the example above, the minified version is 55 characters and the 2-space version is 98, so whitespace almost doubled the size.

Two settings change the output beyond whitespace. Sorting keys makes two objects with the same content print identically, which helps before you compare two JSON files. Setting Unicode Output to ASCII escaped rewrites characters such as é as \u00e9, for systems that only accept plain ASCII.

What the formatter keeps and what it can't

  • Key order stays as written unless you turn on sorting.
  • Numbers keep their exact digits. JavaScript stores numbers as 64-bit floats, so JSON.stringify alone would turn 12345678901234567890 into 12345678901234567000 and 1.0 into 1. This formatter copies every number as written, in the output and in the tree.
  • Duplicate keys collapse to the last one. {"a":1,"a":2} formats as {"a": 2}.
  • JSON5 and JSONC (JSON with comments, like VS Code settings) are rejected because they aren't standard JSON.

Everything runs in your browser tab, so private payloads and tokens are never uploaded. If a value inside your JSON is a token, the JWT decoder will show its claims. To turn the data into a config file, use the JSON to YAML converter.

Frequently asked questions

How do I use a JSON beautifier online?

Paste the JSON into the input box at the top of this page and select Pretty Print. The beautified JSON appears on the right with 2-space indentation, and you can switch to 4 spaces or tabs.

Is this JSON formatter also a JSON validator?

Yes. Every time it formats, it also validates, and with live validation on it checks the JSON as you type. Errors show the line and column where the parser stopped.

Why does my JSON say "Unexpected token"?

The parser met a character that isn't allowed at that spot. The usual causes are a trailing comma, single quotes, an unquoted key or a comment. Go to the line and column in the error badge and check the character just before it.

Can I format JSON that has comments or trailing commas?

No. Comments and trailing commas aren't part of standard JSON, so the validator reports them as errors. Remove them first, then select Pretty Print.

Does formatting change my JSON data?

Only the whitespace changes. Numbers keep every digit, even integers larger than 9,007,199,254,740,991. The one exception is duplicate keys, where only the last value is kept.

Is my JSON uploaded anywhere?

No. Parsing and formatting happen in your browser with JavaScript. The text never leaves your device, so you can format API responses that contain private data.

What keyboard shortcuts does the formatter support?

In the input box, Ctrl+Enter (Cmd+Enter on a Mac) pretty prints. Minify JSON and Validate use their buttons, so the browser keeps its own Ctrl+M and Ctrl+K shortcuts.

Updated 11 October 2026Reviewed by the ToolzyLab teamHow we test our tools