A JSON formatter takes compact or messy JSON and rewrites it with consistent indentation and line breaks so it is easy to read. Paste your JSON, choose 2 spaces, 4 spaces or tabs, and the formatted result appears instantly. If the JSON is invalid, the tool shows the line and column of the first error.
How to use the JSON Formatter
- Paste your JSONPaste an object, an array or any JSON value into the box. A sample is loaded so you can see how it works.
- Choose the indentPick 2 spaces, 4 spaces, tabs or 1 space, and tick "Sort keys" if you want object keys in alphabetical order.
- Copy or downloadCopy the formatted JSON with one click or download it as a .json file. Fix any error at the line and column shown.
What the JSON formatter does
APIs and config files often ship JSON on a single line to save space. That is fine for machines and painful for people. This JSON formatter parses the text and prints it again with one property per line and nested levels indented, so you can scan the structure, spot a missing field or compare two responses.
Formatting never changes the data. Only whitespace is added. Two things are worth knowing:
- Numbers are normalised. The tool uses the browser's own JSON parser, so
1.0comes back as1and integers longer than about 16 digits lose precision, exactly as they would in any JavaScript program. - Duplicate keys collapse. If an object repeats a key, only the last value is kept. The JSON validator warns you about duplicates.
Reading JSON error messages
When the input is not valid JSON, the formatter points at the first problem with its line and column and shows that part of the line. The most common causes are:
- Trailing commas after the last item of an array or object, such as
[1, 2,]. - Single quotes. JSON strings and property names need double quotes.
- Unquoted keys like
{name: "Ada"}, which are valid JavaScript but not valid JSON. - Comments.
//and/* */are not part of the JSON standard. - Raw line breaks or tabs inside a string. Write them as
\nand\t.
Indentation, sorting and privacy
Two spaces is the most common style for JSON and keeps deep structures narrow. Four spaces is easier to read on wide screens, and tabs let each reader choose their own width. Sorting keys makes two JSON documents easier to compare line by line; arrays keep their order because order matters there.
Everything runs in your browser. The JSON you paste is never uploaded, so it is safe to format API responses that contain tokens or customer data. Files of a megabyte or more format in well under a second on a normal laptop. To shrink JSON again, use the JSON minifier.
Frequently asked questions
How do I format JSON online?
Paste the JSON into the JSON formatter, choose an indent of 2 spaces, 4 spaces or tabs, and the pretty-printed result appears straight away. Use the copy button or download it as a .json file.
Does formatting change my data?
No. Only whitespace changes. The one exception is numbers that JavaScript cannot represent exactly, such as integers with more than about 16 digits, and objects with duplicate keys, where only the last value survives.
Why does it say my JSON is invalid?
The usual reasons are a trailing comma, single quotes instead of double quotes, keys without quotes, comments, or a missing bracket. The error message gives the line and column of the first problem.
Is my JSON sent to a server?
No. The formatter runs entirely in your browser with JavaScript. Nothing you paste is uploaded or stored.
How large a file can it handle?
Several megabytes is fine on a modern computer. Very large files are limited by your browser's memory rather than by the tool.
Last updated 24 November 2026 by the TheTechFolk team.