On-device AI — professional-grade, fully private.

JSON Pretty Print Formatter

Format or minify JSON, then browse it as a tree view

  • No upload
  • Long IDs kept exact
  • Repairs broken JSON
  • 25 MB free

Drop a JSON file here

.json · .jsonc · .ndjson · .jsonl · .txt · up to 25.0 MB on Free

Or paste JSON
Formatting
Output
Output

Format for readable JSON, Minify for the smallest valid form.

Indent
Indent

Applied at every nesting level.

Sort keys
Sort keys

Recursive through nested objects. Arrays keep their order.

Duplicate keys
Duplicate keys

Keeping both is the only option that does not delete data.

JSON Lines
JSON Lines

Applies when the file holds more than one top-level record.

Line ending
Line ending

CRLF for files that will be opened in Windows Notepad.

Fixes trailing commas, single quotes, comments and Python literals, and lists every change.

Pro

Free: one file up to 25.0 MB. Pro: up to 1 files, no imposed size cap.

How to format JSON

  1. 1

    Paste or upload your JSON

    Drop a .json, .jsonc, .ndjson, .jsonl or .txt file onto the page, pick one with Browse, or open the paste panel and paste directly. Minified JSON, pretty-printed JSON and JSON Lines all work, and the tool tells you which it found.

  2. 2

    Choose how the output should look

    Pick Format or Minify, then an indent of 2 spaces, 4 spaces or a tab. Optionally sort keys, decide what to do about duplicate keys, and choose LF or CRLF line endings. Every one of these is free.

  3. 3

    Read the result

    The Text view shows the formatted output with syntax highlighting. The Tree view lets you collapse whole branches and copy the JSON path of any value. The Stats view reports what the document contains, including anything that a naive formatter would have changed.

  4. 4

    Fix it if it is broken

    Invalid JSON gets a message, a line and column, and the offending line with a caret under the exact character. If the problem is one a repair can fix, a Repair button appears and tells you afterwards exactly what it changed.

  5. 5

    Download or copy

    Download the formatted file or copy it to the clipboard. Everything happens on your device, so nothing is uploaded and the tool keeps working offline once the page has loaded.

What this JSON formatter offers

This free JSON formatter turns minified or hard-to-read JSON into clear, indented output, and turns indented JSON back into the smallest valid form. Paste or upload your document, choose 2 or 4 spaces or a tab, and read the result as highlighted text, as a collapsible tree, or as a set of statistics about what the document actually contains. If the JSON is invalid you get a line, a column and the offending line marked; if it is repairable you get a repair that tells you exactly what it changed. Everything happens on your device, with no queue and no upload.

  • Pretty print and minify — Convert minified or messy JSON into indented, readable form — or strip every unnecessary byte back out again. Both directions are free and both run in the same pass.
  • Indent options — 2 spaces, 4 spaces or a tab, applied at every nesting level. Tabs suit teams whose code style uses them; the choice changes whitespace and nothing else.
  • Sort keys, four ways — Off, A to Z, Z to A, or natural order that compares digit runs as numbers so item2 comes before item10. Sorting is recursive through nested objects and always leaves array order alone.
  • Tree view with JSON paths — Collapse whole branches to see the shape of a large response at a glance, and copy the path of any value — rows[0].meta.created — straight into your editor, your console or jq.
  • Errors with a line and a column — A specific message, the exact position, and the offending line printed with a caret underneath. Not a character offset into a document that may be a single line long.
  • Repair for broken JSON — Trailing commas, single quotes, unquoted keys, comments, Python literals, smart quotes and missing commas. Opt-in, and it lists every change it made rather than handing back a fixed file and hoping you agree.
  • JSON Lines and NDJSON — A file of one record per line is detected automatically and stays valid JSON Lines, or can be wrapped into a single array on request.
  • Paste, upload, download, copy — Paste from the clipboard, drop a file, or browse for one. Take the result as a download or straight to the clipboard. Pro users can format up to 20 documents and take them as one ZIP.

What your JSON keeps

A formatter is only allowed to change whitespace. That sounds obvious, and almost every online JSON formatter breaks it — including the well-known ones — because they all do the same thing internally: read your document into JavaScript values with JSON.parse, then write those values back out with JSON.stringify. That round trip is lossy in five specific ways, none of which produce an error and none of which look wrong in the output. This tool does not do it. Every number, every string and every key is copied out of your original text character for character, so the only thing that changes is the spacing between them.

  • Long integers survive — JavaScript numbers are 64-bit floats, so any integer above 9,007,199,254,740,991 loses its low digits. 12345678901234567890 comes back from a round trip as 12345678901234567000. That is a snowflake ID, a Stripe object id or a 64-bit primary key turning into a different value in a file you are about to commit.
  • High-precision decimals survive — A coordinate written to eighteen decimal places is rounded to what a double can hold; a value like 1e-400 underflows silently to 0. Both are copied here exactly as written, including the spelling — 1.10 stays 1.10 and 1e2 stays 1e2 rather than being re-spelled as 1.1 and 100.
  • Duplicate keys survive — JSON permits an object to name the same key twice. Reading it into a JavaScript object keeps only the last one, so a formatter that round-trips silently deletes a member. Here both are kept, the Stats view counts them, and the Duplicate keys control lets you resolve them to the first or the last on purpose rather than by accident.
  • Key order survives — JavaScript objects hoist integer-like keys to the front in numeric order. An object written {"2": ..., "1": ..., "name": ...} comes back with 1 and 2 swapped to the front, with sorting switched off, on a tool whose entire job was to change the whitespace.
  • Escapes survive — A string written with \u00e9 or an escaped forward slash is re-spelled by a round trip into the literal character. That is harmless for most data and not harmless when the file is a fixture, a signature payload or anything else compared byte for byte.
  • And it tells you when it mattered — The Stats view reports how many numbers in your document would have lost precision, how many duplicate keys it found, and how many keys would have been reordered — so you can tell whether the tool you used last week was quietly changing your data.

Why format JSON?

Minified JSON saves bandwidth and is close to unreadable. Formatting it with indentation and line breaks makes the structure obvious, so you can debug a configuration file, inspect an API response, or prepare a snippet for documentation without counting brackets. The reverse is just as useful: minifying a document before shipping it strips every byte that only existed for human eyes. Sorting keys gives a stable order so version-control diffs show real changes instead of reordering, and the tree view answers the question a long response usually raises first, which is simply what shape is this.

  • Readability — Indented JSON reveals nesting, arrays and missing fields at a glance. A 40-line response becomes something you can read rather than parse in your head.
  • Stable diffs — Sorted keys remove noisy reordering from version control, so a pull request shows the values that changed instead of the order they were written in.
  • Smaller payloads — Minifying strips indentation and line breaks from a document that no longer needs them. On a typical API payload that is a saving of about 45 percent.
  • Understanding shape — The tree view collapses branches so a thousand-line response fits on one screen as an outline, and every row can hand you the path to the value you were looking for.
  • Trustworthy round trips — Because nothing is re-serialised through JavaScript values, formatting and then minifying returns you to a document that means exactly what the original did.

Reading a JSON error

When JSON will not parse, the useful information is where it stopped and what it found there. This tool reports a specific cause, the line and the column, and prints the offending line with a caret under the exact character. That matters most on a minified document, where a character offset into a single 200,000-character line tells you nothing at all. Here are the causes that actually turn up, roughly in order of how often.

  • Trailing comma — A comma before a closing brace or bracket. Legal in JavaScript and in JSON5, not in JSON. Reported as a trailing comma at the comma, not as a confusing complaint about the bracket after it.
  • Single quotes — 'key': 'value' is JavaScript, not JSON. JSON strings are double-quoted, always. Repair converts them, escaping any double quotes that were inside.
  • Unquoted keys — {key: 1} is a JavaScript object literal. JSON requires every key to be a quoted string.
  • Comments — // and /* */ are common in hand-written configuration and are not part of JSON. Files that use them are often named .jsonc; repair strips them.
  • NaN, Infinity, and Python literals — None of NaN, Infinity, True, False, None or undefined exist in JSON. They arrive constantly from Python's print and from JavaScript consoles. Repair maps them onto null, true and false.
  • Raw newlines inside strings — A literal line break inside a string literal is illegal — it has to be written as \n. This is what happens when someone pastes a multi-line message into a JSON file by hand.
  • Two documents in one file — Content after the end of the first value. Very often this is not an error at all but JSON Lines, which this tool detects and formats rather than rejecting.

Repairing broken JSON

Repair is a checkbox, not a default, and that is deliberate: a repair is a decision about someone else's data. A missing comma can go in two places; a stray backslash can be deleted or escaped. So repair only runs when you ask for it, and when it does it reports every change it made and how many times, in the Stats view, next to the result. It also never touches the inside of a string literal — the document is re-read with a lenient version of the same reader that rejected it, and canonical JSON is written back out from the tokens, so a comma inside a quoted value is never mistaken for structure.

  • What it fixes — Trailing commas, missing commas, missing colons, single-quoted and smart-quoted strings, unquoted keys, // and /* */ and # comments, NaN and Infinity, Python's True, False and None, undefined, hexadecimal and leading-plus numbers, raw control characters inside strings, unterminated strings, and unclosed brackets at the end of the file.
  • What it preserves — Everything the strict path preserves. A repaired document keeps its long integers, its duplicate keys and its key order — the repair fixes the syntax and leaves the values alone.
  • How a stray backslash is handled — A backslash JSON does not define is escaped rather than deleted. C:\qux becomes C:\\qux, which round-trips to exactly what was written; deleting the backslash would silently change a Windows path, which is what most repair tools do.
  • What it will not do — It will not guess at content. If a member has a key and no value it becomes null and says so; if there is nothing recoverable in the file at all it says that rather than handing back an empty document that then fails to parse.

JSON Lines and NDJSON

A great many files with a .json extension are not one JSON document. Application logs, BigQuery and Athena exports, Kafka dumps and OpenAI batch files are all JSON Lines: one complete JSON value per line, no wrapping array, no commas between records. Handed to a normal formatter they produce an error about unexpected content after the first record, which is a technically accurate and completely unhelpful thing to say about a valid file in a common format.

  • Detected, not configured — The shape is worked out by reading the document, not by looking at the extension — plenty of JSON Lines files are called .json, and a pretty-printed single document is full of newlines and would fool any line-counting guess.
  • One record per line, still — By default each record is written back minified on its own line, because a record indented across several lines is no longer JSON Lines. The indent control switches itself off while that is the case and says why, rather than sitting there appearing to do something.
  • Or one array — Switch to Single array and the records are wrapped into a single JSON array and formatted with your chosen indent — usually what you want before handing the data to something that expects one document.
  • Sorting and repair still apply — Every other setting works per record: sort keys, duplicate-key handling, line endings and repair all behave the same way whether the file holds one record or a million.

Options at a glance

  • Output — Format for readable, indented JSON; Minify for the smallest valid form. Both are free.
  • Indent — 2 spaces, 4 spaces or a tab, applied at every nesting level. Inactive while Minify is selected, and while JSON Lines records are being kept one per line.
  • Sort keys — Off, A to Z, Z to A, or natural order. Recursive through nested objects; arrays always keep their order.
  • Duplicate keys — Keep both, keep the first, or keep the last. Keeping both is the default because it is the only option that does not delete data.
  • JSON Lines — One record per line, or all records wrapped into a single array. Only meaningful when the input holds more than one top-level record.
  • Line ending — LF for Unix and for anything going into version control; CRLF for files that will be opened in Windows Notepad.
  • Trailing newline — Ends the file with a newline, which is what POSIX tools and most linters expect.
  • Repair invalid JSON — Off by default. When on, common syntax problems are fixed before formatting and every change is listed.
  • Output file name (Pro) — Name the downloaded file yourself. The default name is derived from the input, so this is a convenience rather than a missing capability.

A 25 MB document formats in under half a second on a current laptop, off the main thread, so the page never freezes.

Frequently asked questions

How does the JSON formatter work?

Paste your JSON or drop a file, choose Format or Minify and an indent of 2 spaces, 4 spaces or a tab, then read the result in the Text, Tree or Stats view. The tool re-writes only the whitespace: it reads your document into a structure of positions in your original text and writes those exact characters back out with new line breaks and indentation. Download the result or copy it to the clipboard.

Is my JSON data secure?

Yes. It all runs on your device, not our servers. There is no upload, no server round trip and no request carrying your data anywhere, so credentials, customer records and internal API responses stay on the machine you pasted them into. The whole tool runs locally, which is also why it keeps working with the network disconnected once the page has loaded.

What indent options are available?

You can format with 2 spaces, 4 spaces or a tab character, applied at every nesting level. Two spaces is compact and common in web projects; four spaces improves readability for deeply nested data; tabs suit teams whose code style uses tab indentation. The choice affects only whitespace, never the data itself. Minify removes indentation altogether, which is why the indent control is switched off while Minify is selected rather than sitting there doing nothing.

Will long ID numbers be changed?

No, and this is the main reason to use this formatter rather than another one. Most online formatters read JSON into JavaScript values and write them back, which rounds any integer above 9,007,199,254,740,991 to the nearest value a double can hold. A Discord or Twitter snowflake ID, a Stripe object id or a 64-bit database key comes back as a different number, silently. This tool copies every number out of your original text character for character, so 12345678901234567890 stays 12345678901234567890. The Stats view tells you how many numbers in your document would have been affected.

What happens to duplicate keys and key order?

Both are preserved by default. JSON allows an object to name the same key twice, and reading a document into a JavaScript object keeps only the last of them, so most formatters delete data without saying so. Here both members survive, and the Stats view counts them. Key order is preserved too, including keys that look like array indices such as "1" and "2" — those get quietly hoisted to the front of the object by any tool that round-trips through JavaScript, even with sorting switched off. If you do want duplicates resolved, the Duplicate keys control offers keep first or keep last.

What does Sort keys do?

Sort keys reorders every object's keys and does so recursively through nested objects, while arrays keep their order. A to Z is plain code-point order, matching what most tools do. Natural order compares digit runs as numbers, so item2 comes before item10 instead of after it, which is what you want for keys like field1 through field12 or version numbers. Sorting produces deterministic output, so version-control diffs show real value changes instead of noise from keys appearing in a different order between exports.

What happens if my JSON is invalid?

You get a specific message, the line and column where parsing stopped, and the offending line printed with a caret under the exact character. Common causes are trailing commas, single quotes, unquoted keys, comments, and Python's True, False and None. If the error is one that can be repaired automatically, a Repair button appears; turning repair on rewrites the document and then lists every change it made, so you can see whether you agree with it before downloading.

Can it handle JSON Lines or NDJSON?

Yes. A file holding several top-level records, one per line, is detected automatically — no setting to find and no need to rename the file. By default each record is written back minified on its own line, which is what keeps the file valid JSON Lines. Switch the JSON Lines control to Single array and the records are wrapped into one JSON array instead, formatted with your chosen indent, which is usually what you want before feeding the data to something that expects a single document.

How large a file can I format?

The free tier handles files up to 25 MB, which covers essentially every API response, configuration file and export people bring to a formatter. Pro removes the imposed cap and works up to what your device can handle, and adds batch formatting of up to 20 files delivered as a single ZIP. Formatting runs off the main thread, so the page stays responsive: a 25 MB document formats in well under a second on a current laptop.

Is it free, and does it work on mobile?

Every formatting feature is free: indent, minify, sort keys, duplicate-key handling, the tree view, the statistics, repair, JSON Lines and line-ending choice. It runs in any modern browser on desktop, tablet and phone, and supports drag-and-drop, download and copy. Pro adds scale and delivery — larger files, batches and a single-archive download — never a different answer.

4.8out of 5

from 1,289 ratings

Rate this tool

Tap a star — it takes a second