Skip to content
Tooletto

JSON Formatter

Paste JSON to pretty-print it with proper indentation, or minify it to the smallest valid output. Invalid JSON is reported with the exact line and column of the problem.

  • Files never leave your device
  • Free, no signup
  • No watermarks
  • Works offline once loaded
Loading tool…

How to json formatter

  1. 1

    Paste your JSON

    Paste or type JSON into the input box. It is parsed as you type.

  2. 2

    Choose a style

    Pick 2-space, 4-space or tab indentation, or switch to minified output.

  3. 3

    Copy the result

    Copy the formatted JSON to your clipboard or download it as a .json file.

Why the same-looking text can be invalid JSON

JSON is a strict subset of what JavaScript object literals allow, and the gap between the two is exactly where most "invalid JSON" errors come from. A trailing comma after the last item in an array or object is legal in modern JavaScript but a syntax error in JSON. Single-quoted strings work fine in JavaScript and are rejected outright by JSON, which requires double quotes. Unquoted object keys — writing `{name: "value"}` instead of `{"name": "value"}` — are valid JavaScript shorthand and invalid JSON. None of these are obscure edge cases; they are exactly the habits picked up from writing JavaScript that quietly produce a document that looks like JSON but is not.

Comments are the other frequent source of confusion, because plenty of config file formats that look like JSON — and even some JSON-derived formats used deliberately — allow `//` or `/* */` comments, while the JSON specification itself has no comment syntax at all. Copying a "JSON" config file that actually contains comments into a strict parser fails immediately, and the fix is either removing the comments or recognising the file was never using standard JSON in the first place.

Why the exact error position matters

A parser that only reports "invalid JSON" without saying where leaves you scanning the entire document by eye for a single missing comma or unescaped quote, which becomes genuinely tedious past a few dozen lines. Reporting the exact line and column of the first problem turns that search into a direct lookup — the error is describing a specific character, not a vague overall failure — which is the difference between fixing a large API response in seconds versus minutes of manual scanning.

It is worth noting the error always points at the *first* problem the parser encounters, not necessarily every problem in the document: a document with two syntax errors will report the first one, and fixing it may reveal the second only on the next attempt, since a parser that has already failed to make sense of the structure cannot reliably keep looking for further issues beyond the first point it got confused.

Formatting versus minifying — different audiences for the same data

Pretty-printed JSON, with consistent indentation and line breaks, exists for the human reading it — debugging an API response, reviewing a config file, understanding a data structure at a glance. None of that structure matters to a program parsing the same JSON, which is why minified output strips every character that exists purely for human readability: indentation, line breaks, and any whitespace between tokens that is not required to separate them. The data represented is identical in both forms; only the number of bytes needed to transmit or store it differs, often substantially for deeply nested structures.

The practical rule is straightforward: format JSON while working with it — reading, debugging, editing by hand — and minify it before it goes anywhere that pays for its size, such as an HTTP request body, a URL query parameter, or a value stored in an environment variable with a length limit.

Frequently asked questions

Is my JSON sent to a server?

No. Parsing and formatting use the browser's built-in JSON engine. Nothing is transmitted, logged or stored, which makes it safe for API responses containing production data.

Why does it say my JSON is invalid?

The most common causes are trailing commas, single quotes instead of double quotes, unquoted keys, and comments — none of which are valid JSON even though JavaScript accepts them. The error message points at the exact position.

What is the difference between formatting and minifying?

Formatting adds indentation and line breaks so the structure is readable. Minifying removes every optional character to make the payload as small as possible, which is what you want when embedding JSON in a request or a config file.

Can it handle very large files?

Documents up to a few megabytes format instantly. Beyond roughly 10 MB the browser's own JSON parser becomes the bottleneck regardless of the tool used.

Common json formatter tasks