My Tool Studio
Developer

JSON Formatter

This JSON formatter takes minified or messy JSON and prints it back with clean indentation, so nested objects and arrays are easy to read. Paste it, drop a file, upload one or load it from a URL, then pick 1, 2, 3 or 4 spaces or tabs and press Format. Minify packs it onto one line instead. Numbers and key order are copied exactly as written, and an optional A to Z sort puts keys in order. Switch the output to Tree to fold and search big payloads, or to JSONPath to pull out values with a query. If the JSON is broken, the bad line is highlighted with a plain-English reason, and Fix common errors repairs trailing commas, single quotes and comments. Formatting runs in your browser.

Always freeNo sign upRuns in your browser
Sort keys
Press Format or Minify, or turn on Auto update.

How to use

01

Add your JSON

Paste JSON into the Input box, drop a .json file on it, press Upload .json, or press Load URL and fetch a public JSON address. Try sample loads a small product record.

02

Choose options and format

Pick an Indent from 1 to 4 spaces or Tab, and a Sort keys order if you want one. Press Format, or Minify for one compact line. Tick Auto update to reformat as you type.

03

Read, copy or explore

Copy or download the result from the Formatted tab. Switch to Tree to fold, search and copy paths, or to JSONPath to run a query such as $..price.

Why JSON Formatter

Format, minify or validate: which JSON tool to use

The JSON tools on this site overlap, but each one is built around a different question. Use the table to pick the right page for the job.

A common flow for broken JSON is to find the error in the validator, fix it, then come back here to format or minify the clean result. When the JSON needs to become another format, the converters take the same pasted input.

TaskToolWhat it does
Make JSON readableJSON FormatterIndents with 1 to 4 spaces or tabs, keeps numbers exact, can sort keys
Browse a large payloadJSON ViewerCollapsible tree, table view, JSONPath and stats
Squeeze JSON onto one lineJSON Formatter or JSON MinifierMinifier adds byte counts, escaped string output and a clean-first option
Find why JSON is invalidJSON ValidatorLine highlight, plain-English reason, auto-fix and optional JSON Schema check
Open JSON in a spreadsheetJSON to CSV or JSON to ExcelFlattens nested objects into columns
Type JSON for a TypeScript projectJSON to TypeScriptInterfaces, type aliases or a Zod schema from a sample

Before and after: one line in, a readable tree out

The sample is a product record squeezed onto a single 224-character line: an id, a name, a price, a stock flag, a tags array, a dimensions object and two variants. Format with 2 spaces turns it into 26 indented lines, where each key sits on its own line and each nesting level steps in by two spaces.

The data does not change. Keys stay in the same order, and 34.5 stays 34.5. Minify reverses the process and gives back the original line. If you sort keys A to Z, dimensions, id, inStock, name, price, tags and variants move into alphabetical order at every level, while the two variants keep their places in the array.

For a payload that is too long to read even when indented, switch to Tree. Top-level keys start open two levels deep, arrays show their length in brackets, and the search box opens every branch that contains your word.

Common questions

What does a JSON formatter change in my data?
Only whitespace. With Sort keys off, the formatter copies every token as written, so 1.0 stays 1.0, 12345678901234567890 keeps every digit and duplicate keys stay visible. Turning on Sort keys parses the data first, which re-prints numbers the JavaScript way and keeps only the last of any duplicate key; the page warns you when that loses precision.
Can I minify JSON with the JSON Formatter too?
Yes. Press Minify and the output becomes one compact line with no spaces between tokens. If you also want byte counts, file upload and download, use the JSON Minifier.
Can I format JSON with tabs instead of spaces?
Yes. Choose Tab in the Indent menu and each level is indented with one tab character. The other choices are 1, 2, 3 and 4 spaces.
Why does the JSON formatter show an error instead of formatted output?
Your input is not valid JSON. The Input box highlights the line with the problem, and the message gives the line, the column and a plain-English reason, such as a trailing comma or a key without quotes. Press Go to line to jump there, or Fix common errors to repair trailing commas, single quotes, comments, unquoted keys and Python True, False and None.
Does formatting JSON keep the original key order?
Yes. With Sort keys off, keys print in exactly the order of your input, including keys that look like numbers. Choose A to Z or Z to A under Sort keys when you want a stable order, for example to compare two payloads.
Is there a size limit for formatting large JSON files?
There is no fixed limit; your browser's memory is the ceiling. Syntax colors switch off above about 80,000 characters so typing stays responsive, and the tree view opens 200 items of a large array at a time with a button to show more. For files of hundreds of megabytes, a command-line tool such as jq is a better fit.
Does the JSON Formatter accept JSON5, comments or trailing commas?
Not as they are, because it follows the strict JSON standard (RFC 8259). Press Fix common errors and the formatter removes comments and trailing commas, converts single quotes, quotes bare keys and replaces NaN, Infinity and undefined with null, then formats the clean result.
Can the JSON Formatter sort keys and collapse sections?
Yes. Sort keys orders every object A to Z or Z to A, at all levels, while arrays keep their order. For folding, switch the output to Tree: each object and array can be opened or closed, Expand all and Collapse all work on the whole document, and the search box opens every branch with a match.
Is my JSON sent to a server when I format it?
Pasted and uploaded JSON never leaves your browser. The one exception is Load URL: browsers block most cross-site reads, so the address is fetched by the site's own server and the text is passed back to your tab, with a 5 MB limit. Use paste or upload for private data.
How do I use the JSONPath tab in the JSON Formatter?
Format valid JSON, then open the JSONPath tab and type a query. $.store.book[0].title picks one value, $..id finds every id at any depth, and $..[?(@.price < 20)] filters items. Matching values and their paths appear below, with buttons to copy them.

More Developer tools

View all