JSON Formatter

Paste JSON to pretty-print, validate or minify it; a paste that fills the editor is formatted at once. Read the result with line numbers and colours, or as a tree that folds. Errors are reported with their line and column, and the line is shown with the spot marked. The whole job runs inside your browser: your data is never sent anywhere.

JSON Formatter

or drop a file here. It stays on this device.

How it works

  1. Paste or type JSON into the editor, or open a .json file from your device. JSON pasted into the empty editor, or over all of its text, is formatted at once with the options below; typing, a paste inside the text and an opened file wait for Format JSON.
  2. Choose the indentation (2 spaces, 4 spaces, tab or minified) and whether object keys should be sorted.
  3. Press Format JSON (or Ctrl+Enter). Read the result as text with line numbers and colours, or as a tree whose objects and arrays open and close; copy it or download it as a .json file. If the input is invalid, the message names the line and column, the editor jumps to that spot and marks the line's number, and the line is shown under the message with the error marked.

Questions

What does the formatter change?

Only whitespace between values, plus the order of object keys if you tick Sort object keys. Sorting is by code point, so digits come before capitals and capitals before lower case, and duplicate keys keep their order. Strings, escapes and numbers are copied exactly as written, so large integers, 0.10 or 1e3 stay unchanged; JSON.parse-based formatters would rewrite those.

Does it format as soon as I paste?

Yes, when the paste fills the empty editor or replaces all of its text: it is formatted with the options chosen, as if you had pressed Format JSON, and the cursor stays in the editor. A paste inside the text, typing and an opened file wait for Format JSON or Ctrl+Enter, so a half-edited document is not reported as an error while you work on it.

What do the text and tree views show?

The same result, the one Copy and the download give; switching views changes neither. The text view numbers the lines and colours keys, strings, numbers, true, false, null and punctuation; a line longer than 10,000 characters is coloured up to there, and a minified result, a single line, is shown plain. The tree shows each object and array as a line that opens and closes, with how many keys or items it holds: it reads \u escapes as the characters they stand for (control characters stay escaped), shows up to 10,000 characters of a string, opens 1,000 members at a time and 100 levels deep (a deeper object or array is named, and the text view shows it), and offers Expand all for documents of up to 5,000 values.

How strict is the validation?

It follows the JSON standard (RFC 8259): double-quoted keys and strings, no trailing commas, no comments, no single quotes, no NaN or Infinity. Each problem is reported with its line and column; the cursor moves there, the line's number is marked, and the line is shown under the message with the problem marked. JSON5 or JSONC input is reported as invalid, not fixed.

How big can the JSON be?

The formatter itself takes under half a second for a 15 MB file; showing the result on the page takes a few seconds more at that size. The editor is the practical limit: above roughly 20 MB the browser gets slow displaying the text, so the box shows at most a result's first 2,097,152 characters, with the full file available for download, and files above 32 MB are refused. Nesting deeper than 1000 levels is refused.

Does it work offline?

Keep a connection for the first successful format, while the formatter finishes loading. After that, you can disconnect and keep formatting in this open page. Your JSON is processed on your device and is never uploaded.

Is my text uploaded?

No. The page loads a small script into your browser and every operation runs on your device. You can check this yourself in the browser's network panel: after the page has loaded there are no upload requests. Closing the tab discards the text.

Do I need an account or to pay?

No. These basic tools are free and add nothing to your data. The only limits are the tool's own: opened files up to 32 MB, nesting up to 1,000 levels; pasted text is bounded only by what the browser's editor can hold. Within them, the practical limit is your device's memory.

What does this page keep in my browser?

Nothing you open or type. While the tab is open, the tool pages keep a short list of the steps taken in it, in the tab's session storage: the step (page opened, started, succeeded, first success, used again or failed), the tool's name, the time, how many files were used and, for a failure, an error code; never a file name, the contents of a file or your text. It holds at most the latest 200 steps, and the browser deletes it when the tab closes. The page never sends it. Where a Report a problem button is shown, you can attach the last 20 steps to your report; nothing is attached unless you tick that box. In local storage the page keeps only choices you made: a Light or Dark theme until you choose System again, the language you picked with the EN / 中文 switch if it differs from your browser's language, and this tool in your recently used list if you switched that list on at the tools page.

Questions or problems

Found a problem or missing feature? Tell us. Please describe the steps; do not send confidential data.