Free JSON prettifier

One line of JSON, made readable.

Free JSON prettifier. Paste minified or messy JSON and get back a clean two-space indented version. Runs in your browser, nothing uploaded.

Paste your text to begin
0 chars / 0 words
bytes uploaded
0
per indent level
2 spaces
usage limit
None

JSON prettifier

What the JSON prettifier does

Paste JSON in any state, one giant minified line, inconsistently indented, or copied out of a terminal with the formatting stripped, and this JSON prettifier parses it and hands back a version with two-space indentation and one value per line, so the nesting is visible at a glance.

It runs in your browser. Nothing you paste is sent anywhere, there is no signup, and there is no cap on how much JSON you format. Most of the well known formatters do not tell you where your data goes. This one does: it goes nowhere.

Why it matters

Why pretty-printed JSON is easier to read than one long line

A minified API response is often a single unbroken line, sometimes tens of thousands of characters long. Reading it means scanning left to right through braces and brackets with nothing to anchor on, trying to hold in your head which closing brace belongs to which opening one.

Reformatted with indentation, the same data reads the way code reads. Depth is visible from the indentation alone, and finding one key is a matter of looking down the left edge rather than counting characters across.

How to

How to prettify JSON in three steps

Nothing to install, nothing to configure.

Step 1
Paste the JSON into the input box, in whatever shape it is currently in.
Step 2
Press Format. It parses and re-indents immediately, on your own device.
Step 3
Copy the readable result out of the output panel.

Common failure

Why the JSON prettifier says Invalid JSON

If the tool rejects your text, the parser could not read it as JSON. It does not guess, and it does not repair. A handful of causes account for almost every rejection, and they are all things JSON simply does not allow.

Fix the offending character and paste again. The message is the same for every cause, so it is worth knowing the short list.

Trailing comma
A comma after the last item in an object or array. Legal in JavaScript, not in JSON.
Single quotes
JSON strings and keys must use double quotes. 'name' is not a JSON string.
Unquoted keys
{ name: 1 } is a JavaScript object literal. JSON needs { "name": 1 }.
Comments
Neither // nor /* */ is part of JSON, however common they are in config files.
NaN, Infinity, undefined
None of these are JSON values. Only numbers, strings, booleans, null, objects and arrays.
A wrapper around the JSON
A log prefix, a shell prompt, or a stray closing bracket copied along with the payload.

The indent

Why this JSON formatter uses two spaces

The indent here is fixed at two spaces per level. There is no dropdown, because two spaces is what the JavaScript and TypeScript world overwhelmingly uses, and it is the width most JSON you will meet already carries.

Two spaces also keeps deeply nested data inside a reasonable line width. At four spaces, a structure six levels deep starts at column twenty-four before a single character of content, which pushes long values off the side of the screen.

In code

How to pretty print JSON in JavaScript and Python

This tool is a browser front end for something your language already does. If you would rather do it in a script, both of these produce the same two-space output.

Both take a parsed value, not a string of JSON. In JavaScript that means JSON.parse first if you are starting from text; in Python it means json.loads first.

JavaScript
JSON.stringify(value, null, 2) returns the indented string. The null is the replacer argument, which you rarely need.
Python
json.dumps(data, indent=2) does the same. Add sort_keys=True if you want alphabetical keys, which this tool does not do.
Command line
Piping through a JSON-aware CLI tool will also reindent, which is handy when the payload is already in a shell pipeline.

The pair

JSON prettifier versus JSON minifier

These are opposite operations on the same data. Prettifying adds whitespace so a person can read it. Minifying strips whitespace so a machine can move it in fewer bytes. Neither changes a single value.

Use the prettifier when you are reading, debugging or committing a file. Use the minifier when you are sending the payload over a network or embedding it where size matters. You can go back and forth as many times as you like without losing anything.

Who it's for

Who uses a JSON prettifier, and when

Developers paste a minified API response in mid-debug, just to see the actual shape of what came back instead of a wall of text. People reviewing a pull request run a JSON fixture through it before committing, so the next diff on that file is readable line by line instead of showing one enormous changed line.

Support and QA staff use it on a raw payload pulled out of a bug report or a log line. And anyone handed a config file with no formatting uses it to find the one setting they came for.

FAQ

JSON prettifier questions

Everything below is answered in full, nothing to click open.

How do I prettify JSON?

Paste it into the input box and press Format. The indented version appears in the output panel, ready to copy.

Is the JSON prettifier free?

Yes. No signup, no length cap and no run limit, because the formatting happens on your own device.

Is my JSON uploaded anywhere?

No. Parsing and formatting both run in your browser. Nothing is transmitted, stored or logged.

Is it safe to paste JSON with API keys or customer data?

The text never leaves your browser, so nothing is exposed to us. Normal care about your own screen and clipboard still applies.

How many spaces does it indent with?

Two spaces per nesting level, fixed. There is no setting to change it to four spaces or tabs.

Can I choose tabs instead of spaces?

No. The output is always two spaces per level. If you need tabs, reformat in your editor after pasting the result in.

Does it change any of my data?

No. Only whitespace changes. Every key, value and array item comes back exactly as it went in.

Why does it say Invalid JSON?

The text does not parse as JSON. The usual causes are a trailing comma, single quotes, unquoted keys, or a comment, none of which JSON allows.

Does it tell me which line the error is on?

No. It reports that the input is invalid without a line or column number, so you will need to scan for the cause yourself.

Does it fix broken JSON?

No. It parses or it rejects. There is no repair step, so malformed input has to be corrected before formatting.

Does it accept JSON5 or JSONC with comments?

No. Standard JSON allows neither comments nor trailing commas, so both need removing first.

Does it sort keys alphabetically?

No. Keys keep the order they arrived in. Formatting only adds whitespace, it does not reorganise anything.

Is there a size limit on the input?

No cap is imposed. The practical ceiling is your own device's memory, since the work happens in the browser tab.

Does it work on phones?

Yes. The layout adapts to narrow screens, and the formatting runs the same way.

What is the difference between this and the JSON minifier?

This adds indentation and line breaks so JSON is readable. The minifier strips whitespace to make it smaller. They are opposites on the same data.

Can I format an array instead of an object?

Yes. Any valid JSON value formats, including a bare array, a string or a number.

Does formatted JSON mean the data is correct?

No. It only means the syntax parses. A wrong value, a missing field or a number stored as a string will format perfectly.

Does it validate against a schema?

No. It has no concept of a schema and cannot tell you whether the values themselves are right.

Can I upload a .json file?

No. This is a paste field, so open the file, copy the contents, and paste them in.

Does it show a collapsible tree view?

No. The output is plain indented text. There is no folding, no colour coding and no tree.

Can the output be used directly in code?

Yes. Indented JSON is exactly as valid as minified JSON to any parser. The whitespace has no effect on how it is read.

Is there an API or batch mode?

Not at the moment. This is a single-paste tool in the browser.

Turn one line of JSON into something you can read.

Two-space indentation, in your browser, with nothing uploaded and no run limit.

Open the JSON prettifier