Input

Paste, type or upload some JSON to get started.

Output

What Is a JSON Formatter?

JSON (JavaScript Object Notation) is the most widely used data exchange format on the web. APIs return it, config files use it, databases store it, and when something breaks or looks wrong, you need to actually read it. The JSON specification keeps things intentionally minimal, which is great for machines but genuinely painful when you're trying to debug a deeply nested API response. A JSON formatter solves that: it adds indentation and line breaks to raw or minified JSON so the structure is immediately clear.

All of the work happens inside this browser tab. Your JSON is laid out the way JSON.stringify() would print it, with 2 spaces unless you pick 4 or a tab, but numbers and strings keep the exact characters you typed. A SIM serial like 8901240544102066246 stays all 19 digits, a price of 1.50 keeps its trailing zero and 1e5 is not rewritten as 100000. No request carries your data off the page, which is why production payloads, tokens and anything else you'd rather keep private are fine to paste here.

JSON Formatting Examples

Here are some examples of what the formatter does. Minified or compact JSON is hard to read; formatting it reveals the structure at a glance.

Example 1: Subscriber record

Minified input (single line):

Input

Formatted output:

Output

Example 2: Call records

Minified input:

Input

Formatted output:

Output

Click the Sample button above to load a ready-made example (mobile plan data) into the editor and see the formatter in action.

How to Use This Tool

1

Paste or Upload

Drop a response body or a settings file in the left pane, press Paste to pull in whatever is on your clipboard, or open a file from disk with Upload (.json and .txt are accepted). Files are reindented on the way in, so a one-line export lands in the editor already readable. The browser may ask before it lets Paste read the clipboard; if it says no, Ctrl+V in the editor does the same job. Sample drops in two mobile plan records to try it on.

2

Pick an Indent, Sort, or Filter

Pause for roughly a third of a second and the right pane redraws. The Indent list switches between 2 spaces, 4 spaces and a tab. Sort keys A to Z puts every object's keys in order and leaves arrays alone. Filter takes a JSONPath expression such as $[*].planName and shows only what it matches, as an array. Anything that parses under RFC 8259 gets laid out, including a whole document wrapped in quotes, which is unwrapped first.

3

Read the Status Line, Then Copy or Download

The line under the input says Valid JSON with the top-level type and the size, or names the line and column where parsing stopped and tints that line red. Click the message to put the cursor on it. Once it reads valid, Copy puts the output on your clipboard, Download saves it as formatted.json with your indent, sort and filter applied, and Minify squeezes it onto one line. Full screen gives both editors the whole window, and Esc brings the page back.

How the Formatter Works

Both panes are code editors with syntax highlighting and line numbers. When you paste or type JSON in the input panel, the tool waits 300ms (to avoid parsing mid-keystroke), then reads it with a strict parser that accepts exactly what JSON.parse() accepts. The difference is that it keeps each number and string as the text you wrote instead of converting it, so sorting, filtering and re-indenting never touch a value. It also knows where it stopped, which is how a missing comma comes back as a line and column rather than a bare "invalid".

Worth noting: JSON does not support comments. That's defined in the spec itself, not a limitation of this tool. Files like VS Code's settings.json use JSONC (JSON with Comments), which is a different format. If your file has comments, you'll need to remove them before formatting.

Where JSON Formatting Helps

The everyday case is a response body you can't read. Postman pretty-prints for you, but curl, a log line or an error report usually hands you one long string with every brace on the same row. Paste that here and the nesting shows up as indentation, which is where you spot the array that should have been an object. Once you know which field you're after, jq can pull it out of the next thousand responses in a shell script.

Config files are another common case. A package.json or tsconfig.json with inconsistent indentation turns a pull request diff into noise. Formatting it here gives you a consistent version you can paste back. If you need to combine two config files, there's a separate JSON Merge tool for that.

Document stores are the third. A MongoDB export in Extended JSON, a Firestore dump or a CouchDB _all_docs call arrives as a dense blob where wrappers like {"$oid": ...} hide among the real fields. Laying a single document out with indentation shows which keys are nested and which are arrays before you write the import script. If the data really belongs in a spreadsheet, try JSON to CSV to convert it.

Hand-written test fixtures and sample payloads copied out of API docs are worth a pass here too, since a missing comma in a fixture fails a test for the wrong reason. It's also useful before sharing JSON with teammates. Formatted JSON in a Slack message or a Jira ticket is much easier to read than a raw minified string. Running it through the JSON Validator first can catch issues before anyone else sees them.

Frequently Asked Questions

Is it safe to paste real API keys or sensitive data here?

Yes. Parsing, sorting and the JSONPath filter all run inside the page, and no request goes out with your text. If a bearer token or customer email is in there, it stays in the editor until you press Clear or close the tab. Paste only reads the clipboard at the moment you click it. There is no sign-in and no history kept between visits.

What's the size limit?

There's no hard limit from the tool itself. It depends on your browser's available memory. JSON files up to 10-15 MB generally work without issues in Chrome and Firefox. For very large files (hundreds of MBs), a command-line tool like jq is more practical.

Why would I need to minify JSON?

Minified JSON has all whitespace stripped, no line breaks, no spaces, just the raw data. That makes it smaller to send over a network, cheaper to store in a database field, and safe to embed in a URL. The Minify button does this on the current output. There's also a dedicated JSON Minifier page if that's your primary use case.

Why does the output say "Invalid JSON"?

The input has a syntax error, and the status line under the input tells you where. Load the sample and delete the comma after "price": 20, for instance, and it reads Line 6, column 5: Expected a comma or } after the value, with line 6 tinted red. Common causes are a trailing comma after the last element, single quotes instead of double quotes, unquoted property names and mismatched brackets. The JSON spec is strict about all of these.

What does Sort keys A to Z change?

Only the order of keys inside objects, at every depth. Values stay untouched and arrays keep their order, because in an array the position usually means something. Turn it on with the sample loaded and each plan starts with "data", then "minutes", "planId", "planName", "price", "sms" and "validity". Keys are compared by character code, the same order jq -S and Python's sort_keys=True give, so "Zone" lands before "apn". It is handy before diffing two API responses whose fields come back in a different order each time. Minify and Download keep the sorted order.

How do I filter the output with JSONPath?

Type an expression into Filter. It starts with $, which stands for the whole document. With the sample loaded, $[*].planName gives ["Basic Plan", "Premium Plan"], $[?(@.price > 30)].planName gives just ["Premium Plan"], and $..planId collects every planId at any depth. Matches always come back as an array, laid out with your indent and sorted if Sort is on, and long numbers stay exact. A path that matches nothing says so in the status line under the output, and a half-typed expression waits until its brackets are closed. JSONPath was written down as RFC 9535 in 2024; this filter follows the older, widely used syntax, which agrees with the RFC on everyday paths like these. Clear the box to get the whole document back.

Can this validate JSON against a schema?

This tool validates syntax (whether the JSON is well-formed), not structure. For schema validation, use the JSON Schema Generator to generate a schema from sample data, or the JSON Validator for more detailed checks.

Related Tools

For a deeper look at JSON, MDN's JSON.stringify() reference explains the indent argument this page mirrors. The formal standard is RFC 8259. See also json.org and jq.