Skip to content

Runs entirely in your browser. Nothing you paste leaves this page.

Free / No sign-up

JSON formatter and validator.

Pretty-print, minify and validate JSON with the exact line and column of every syntax error, plus a collapsible tree view. Free, and it runs entirely in your browser.

Indentation

Output

Output view
Valid. Press Format or Minify.

Valid JSON: an object with 6 keys.

How to use it.

  1. 01

    Paste JSON or load the sample. It is validated as you type.

  2. 02

    Press Format (2 spaces, 4 or tabs) or Minify, or switch the output to Tree.

  3. 03

    If it is invalid, press Show me to jump to the exact line and column.

What it does.

Everything this tool handles, all of it inside your browser tab.

  • Validates as you type, with no button to press
  • Plain-English errors with the exact line and column
  • Show me jumps the cursor straight to the error
  • Format with 2 spaces, 4 spaces or tabs
  • Minify to a single line
  • Collapsible tree view with key and item counts
  • Summary of the top-level value, such as an object with 6 keys
  • One-click copy of the output
  • Runs entirely in your browser: no upload, no sign-up

Worked examples.

  • Fix a trailing comma in JSON

    {
      "name": "Ada",
      "roles": ["admin", "dev",]
    }
    
    > Trailing comma before ] at line 3, column 28.

    Delete the comma after "dev". Show me puts the cursor on the closing bracket so you can fix it without hunting.

  • Single quotes and unquoted keys

    {'id': 1}
    
    > Expected a double-quoted property name at line 1, column 2.
    
    Fixed:
    {"id": 1}

    JavaScript object literals accept single quotes and bare keys. JSON does not: every key and string needs double quotes.

  • Missing comma between properties

    {
      "user": "ada"
      "admin": true
    }
    
    > Expected , or } after the value at line 3, column 3.

    The error points to the start of "admin" on line 3, but the missing comma belongs at the end of line 2.

  • Minify JSON to one line

    {
      "id": 7,
      "tags": ["a", "b"],
      "active": true
    }
    
    > {"id":7,"tags":["a","b"],"active":true}

    Minify removes all insignificant whitespace. The data is identical; it is just smaller to send or store.

  • Large numbers lose precision

    {"id": 9007199254740993}
    
    > Formatted:
    {
      "id": 9007199254740992
    }

    Integers above 2^53 - 1 cannot be represented exactly as JavaScript numbers. Send large IDs as strings, such as "9007199254740993".

What is a JSON formatter?

A JSON formatter takes compact or messy JSON and rewrites it with consistent indentation so people can read it. A JSON validator checks that the text follows the JSON grammar at all. This tool does both: it validates on every keystroke, then formats with 2 spaces, 4 spaces or tabs, minifies to a single line, or shows the data as a collapsible tree.

Under the hood there are two steps. A small scanner written for this page walks your text character by character and stops at the first rule it breaks, so it can report a plain-English message with an exact line and column. Browsers word JSON.parse errors differently and some omit the position, so the scanner gives the same answer in every browser. Once the text is valid, the browser's own JSON.parse builds the value and JSON.stringify writes the formatted or minified output.

If you work with JSON every day, you are probably reading API responses, config files or log lines. Formatting makes them reviewable; validation tells you why a parser rejected them.

What makes JSON valid? The RFC 8259 rules

JSON is defined by RFC 8259 and ECMA-404. A JSON text is one value: an object, an array, a string, a number, or one of the literals true, false and null. Since RFC 8259 the top-level value can be any of these, not only an object or array, so a bare "hello" or 42 is valid JSON.

The rules are strict. Object keys must be strings in double quotes. Strings use double quotes only, and line breaks, tabs and other control characters inside them must be escaped as \n, \t or \u0000-style sequences. Numbers are decimal: no leading zeros (01), no leading plus sign, no hexadecimal, and no NaN or Infinity. The literals are lowercase. Commas separate items but may not follow the last one, and there is no syntax for comments.

Two softer rules matter too. JSON exchanged between systems should be encoded as UTF-8, and the names in an object SHOULD be unique. The specification does not say what happens with duplicates, so different parsers behave differently.

Common JSON errors and how to fix them

Trailing commas are the most common error, usually left behind after deleting the last item of a list. Next come single-quoted strings and unquoted keys, which are fine in JavaScript object literals but not in JSON. Pasting a Python dict gives True, False and None, which must become true, false and null.

A missing comma between two properties is reported at the start of the second one, because that is where the parser first notices something is wrong. The same applies to a missing closing bracket: the error often points further down than the real mistake, so read the line above too.

"Unexpected token < in JSON at position 0" (or "is not valid JSON" in newer browsers) means the response was not JSON at all. It is usually an HTML error page, a login redirect or a proxy message. Check the status code and Content-Type header of the response rather than the JSON itself; the REST API design best practices guide covers returning JSON errors consistently.

"Unexpected content after the JSON value" means two documents are glued together. That is normal for JSON Lines (NDJSON), where each line is its own document: validate one line at a time.

Formatting re-serialises your data: edge cases to know

Format and Minify parse your JSON into a JavaScript value and write it back out, so the output is equivalent data, not a character-for-character copy with new whitespace. In everyday payloads you will not notice. In a few cases you will.

Numbers become JavaScript doubles. Integers above 9,007,199,254,740,991 (2^53 - 1) lose precision, 1.50 becomes 1.5 and 1e3 becomes 1000. Escapes are normalised, so "\u00e9" is written as é. With duplicate keys only the last value survives. Keys that look like non-negative integers, such as "2" and "10", move to the front of their object in ascending order, because that is how JavaScript orders object properties.

If any of that matters, for example in a signed payload or a file you diff byte by byte, use the validator only and keep your original text. To compare two versions of a document after formatting both, use the text diff checker.

JSON vs JSON5, JSONC, YAML and NDJSON

JSON5 and JSONC (JSON with comments, used by many editor and TypeScript config files) relax the rules: comments, trailing commas and, in JSON5, single quotes and unquoted keys. They are convenient for hand-edited config, but a strict JSON parser will reject them, which is exactly what this validator reports.

YAML is a superset of JSON aimed at human-written config, with indentation instead of brackets. NDJSON stores one JSON document per line for logs and streaming. For typed code, the JSON to TypeScript converter turns a sample payload into interfaces you can paste into a project.

Is it safe to paste JSON into an online formatter?

With this one, yes. Validation, formatting and the tree view run in JavaScript inside your browser tab. There is no upload step, no account and no server-side processing, so internal API responses and customer records never leave your machine. You can confirm it by opening your browser's developer tools and watching the Network tab while you format.

Very large documents of many megabytes format quickly, but the tree view renders every node, so it can become slow. Use the text view for those.

Questions, answered

Something else on your mind? Ask a consultant and get a reply within one business day.

Is my JSON uploaded anywhere?

No. Formatting, validation and the tree view run in JavaScript inside this tab. Nothing is sent to a server, so it is safe for internal payloads and customer data.

What is the difference between a JSON formatter and a JSON validator?

A validator checks whether text is valid JSON and tells you where it breaks. A formatter rewrites valid JSON with readable indentation, or minifies it. This tool validates first, then formats, because invalid JSON cannot be formatted reliably.

How do I fix "Unexpected token in JSON at position 0"?

That error means the text is not JSON at all, most often an HTML error page or a redirect returned by the server. Check the response status code and Content-Type before parsing. If it is JSON, paste it here to find the exact problem.

Does it support comments or trailing commas?

No, because standard JSON does not. Those are features of JSON5 and JSONC. The validator points to them so you can remove them before an API or parser rejects the file.

Why are large numbers changed after formatting?

JavaScript numbers are 64-bit floats, so integers above 9,007,199,254,740,991 lose precision when parsed. Send very large IDs as strings to keep them exact.

Why did a key disappear after formatting?

Your JSON probably contains the same key twice in one object. JSON.parse keeps only the last value, so the formatted output has one copy. Duplicate keys are allowed by the grammar but discouraged by RFC 8259, and parsers handle them differently.

Why did the order of my keys change?

Keys that look like non-negative integers, such as "1" or "42", are moved first in ascending order. This is how JavaScript orders object properties. Other keys keep their original order.

Is a single string or number valid JSON?

Yes. Since RFC 8259, any JSON value can be the top-level value, including "text", 42, true or null. Some older parsers only accept an object or array at the top level.

Can it format JSON Lines (NDJSON)?

Not as one document. NDJSON has one JSON value per line, so the validator reports unexpected content after the first value. Paste one line at a time to check it.

Should I indent JSON with 2 spaces, 4 spaces or tabs?

It is a style choice with no effect on the data. Two spaces is the most common convention in JavaScript projects and API documentation; match whatever your codebase or formatter already uses.

How large a file can it handle?

Several megabytes format comfortably in a modern browser. Very large files may make the tree view slow; use the text view for those.

More free tools.

All tools

Need tooling like this inside your product?

We build internal tools, developer platforms and APIs. Tell us what your team keeps doing by hand.