JSON Formatter

Format, beautify and validate your JSON data

Input

Waiting for JSON: type, paste or upload a document on the left.

Output

Paste your input on the left and the result shows up here.

Or drop a file on this box, , or .

What is JSON Formatter?

A webhook payload in your logs, a curl response, a package-lock.json someone minified: JSON (JavaScript Object Notation) often arrives as one long line, and the bug you are chasing is buried somewhere in the middle of it. Paste it here and every object and array gets its own indented block, so you can scroll to the field you care about instead of counting braces. When indented text still isn't enough and you want rows and columns, the JSON parser that shows a table lays the same document out with a filter box over each column.

JSON is what most web APIs speak, and MDN's JSON reference is a good place to look up how JavaScript reads and writes it. The formatter parses your input under the RFC 8259 JSON specification and re-prints it with 2-space indentation unless you switch the Indent list to 4 spaces or tabs, so anything it formats is valid JSON. Values are never converted on the way through: a 19-digit ID keeps every digit, 45.20 keeps its trailing zero and 1e3 is still written 1e3. And if you paste a JSON document that was itself stored as a quoted, escaped string (common in logs), it's unwrapped and formatted as the document inside.

This page has no backend step and no share link. Parsing, sorting, filtering and re-printing are done by the JavaScript engine of the tab you are reading, which matters when the payload holds customer emails or an access token you would rather not paste into a stranger's server. Paste reads your clipboard once, at the moment you press it, and only if the browser agrees.

How to Use the JSON Formatter

You never press Format here. About 300ms after you stop typing, the right panel re-parses the input and prints it again. The bar above the editors decides how it gets printed, and the strip under each editor tells you what just happened.

1

Paste, Upload, or Load Sample

Paste the one-liner on the left with Ctrl+V, or press Paste and the page reads the clipboard for you (the browser asks first, and if you say no, a message tells you nothing was pasted). Upload picks a response you saved from DevTools (it takes .json and .txt), and Sample drops in two minified subscriber records. A typical paste from an order API looks like this:

{"orderId":"ORD-55012","customer":{"name":"Ava Chen","loyalty":"gold"},"items":[{"sku":"SKU-412","qty":2,"price":14.5},{"sku":"SKU-318","qty":1,"price":42}],"paid":true}

Leave off the final } of that line and the strip under the input turns red: "Line 1, col 169: The JSON ends before everything is closed." The line is tinted in the editor as well, and clicking the message drops your cursor on the exact column. Fix it there and the output comes back.

2

Choose an Indent, Sort the Keys, or Filter

Formatted JSON shows up in the Output panel a moment after you stop typing, with 2 spaces per level unless the Indent list says 4 spaces or Tabs. Turn on Sort keys A to Z and each object, nested ones included, is printed with its keys in alphabetical order, while array items stay where they were. The JSONPath box cuts the output down to what an expression matches: on the sample, $[*].plan returns ["Unlimited 5G", "Family Plan"]. The strip under the output names the layout and key order you are looking at.

3

Copy, Download, Minify, or Go Full Screen

Copy takes the output for a ticket or a pull request, Download writes it to formatted.json, and Minify flips the same document back to a single line when you need to paste it into a cURL body. Sorting and the JSONPath filter carry through all three. Full screen hides the page header so the bar and both editors get the whole window, and Esc puts the page back. Clear wipes the input, and the output follows. The parsing follows the rules of JSON.parse(), so a trailing comma is reported as an error rather than silently dropped.

When You'd Actually Use This

API Development

API responses often come minified. Format them to understand the structure, debug issues, or document endpoints. Works the same for a REST response, a Swagger/OpenAPI spec saved as JSON, or a GraphQL response body.

Config File Review

A tsconfig.json, an appsettings.json or a Terraform state file that a script rewrote on one line. Reformat it before you review the change, and a flag that moved into the wrong section stands out by its indentation.

Learning JSON

Teaching someone JSON? Paste a real response from a public API and walk through it together: curly braces are objects, square brackets are lists, and the indentation shows which record each field belongs to.

Debugging

Trying to find a bug in your JSON? If it doesn't parse, the error message points at the spot. If it does, the indentation makes wrong nesting easy to see, like a field that ended up inside the wrong object.

Common Questions

Is my JSON data stored?

No. Parsing, sorting and the JSONPath filter are all done by this page's own script. There is no save or share feature, and Upload only reads the file into this tab, so the payload is never transmitted or stored.

What JSON formats are supported?

We support all valid JSON according to the ECMA-404 standard. Objects, arrays, nested structures, strings, numbers, booleans, null - everything standard JSON supports.

Can I format invalid JSON?

No. The formatter parses your JSON first, and when that fails the output only says Invalid JSON and why. The red strip under the input gives the line and column, for example Line 1, col 2: Strings and property names need double quotes, not single quotes. for {'subscriberId': 'SUB-1001'}, and a click on it moves the cursor there. Fix the syntax error and the output updates. For common mistakes like trailing commas or single quotes, the JSON Fixer can repair them for you.

What indentation does it use?

Two spaces per level until you change it. The Indent list in the bar above the editors also offers 4 spaces and Tabs, and the same choice is used when Upload re-indents a file into the input pane.

How big can my JSON file be?

The code sets no cap of its own. Responses of a few MB format without trouble; beyond that the bottleneck is the editor drawing hundreds of thousands of lines, not the parse. For a 50 MB log export, a command-line tool such as jq is the better fit.

What does Sort keys A to Z do to my data?

It only moves keys. Every object, however deep, gets its keys in A to Z order, while values and the order of array items stay exactly as they were. On the sample, each record comes out as dataUsage, plan, status, subscriberId. Ordering goes by character code, so capitals sort first: "SKU" lands ahead of "price", which is also how jq -S orders them. Turn it on before you diff two responses whose fields arrive in a different order every time.

How does the JSONPath box work?

Type a path beginning with $, which stands for the whole document, and the output shrinks to an array of whatever it matches. With the sample loaded, $[*].subscriberId lists both IDs, $[?(@.dataUsage > 100)].subscriberId keeps only "SUB-1002", and $..status collects every status field at any depth. A path that finds nothing gives [] and a yellow note under the output, and while a bracket or quote is still open the note asks you to close it. The syntax is the long-standing one that came before RFC 9535, the JSONPath standard published in 2024, and the two read simple paths like these the same way. Empty the box to see the full document again.

Other JSON Tools You Might Need

Once the document is readable you usually want to do something with it: validate it against your expectations, shrink it again, turn the records into a spreadsheet, or describe its shape as a schema. These pages cover that: