About the formatter
JSON Formatter: format, beautify and minify JSON.
Your document never leaves the browser.
- no sign-up
- works offline
Turn compact JSON into readable text, or make it small again, without sending the document away. This is the same workspace as the JSON editor, opened with Code ready on the left and a second view beside it. Read the Format, Minify and Sort keys note or the broader Repair guide.
What JSON formatting changes
Before
{"name":"Ada","tags":["JS","Go"]}After
{
"name": "Ada",
"tags": [
"JS",
"Go"
]
}JSON often arrives as a single dense line because compact text is efficient to transmit. That shape is awkward for review: closing brackets are hard to pair with their openings, neighbouring records blur together, and a deeply nested value takes effort to locate. Formatting inserts insignificant whitespace around the existing tokens so containers and members form a visible outline. It changes the presentation of the document, not the data a conforming JSON reader receives.
This page opens in Mirror with Code on the left, putting editable text beside another view of the same document. Paste or open JSON, then press Format in either pane toolbar or use the editor band. The action is one undoable change. The status bar continues to report validity and UTF-8 size, while the other pane follows the same document so you can check the structure as soon as the rewrite lands.
Choose two, three, four spaces or a tab
Input
{"user":{"name":"Ada","active":true}}4 spaces
{
"user": {
"name": "Ada",
"active": true
}
}Tab
{
"user": {
"name": "Ada",
"active": true
}
}The default style uses two spaces for every nesting level. Settings offers four explicit choices: 2 spaces, 3 spaces, 4 spaces or a tab. Format reads that choice when you press it, and the Code editor uses the same unit for indentation, so typing and formatting do not fight over the layout. Empty objects and arrays stay compact as {} and []; populated containers put one member or item on each line.
Formatting keeps object members and array elements in their present order. It also keeps the source spelling of strings, including escapes, rather than decoding and re-encoding them. That restraint matters in review: a button intended to improve spacing should not turn an escaped slash into a plain one or make an unrelated line appear changed.
Minify when the document is ready to ship
Minify performs the inverse layout operation. It removes every space, tab and line break that JSON grammar does not require, while preserving the tokens themselves. The result is useful for a request body, a fixture or any place where readability matters less than byte count. Format and Minify can be alternated without rounding a number or normalising a string, and each press remains a single step in the undo history.
Whitespace inside a quoted string is data, so it is never stripped. A value such as "first line\nsecond line" keeps its escape, and a sentence keeps the spaces between its words. Only separators outside values are tightened: commas, colons and the gaps around brackets and braces.
Sort keys without moving array items
Before
{
"z": 0,
"items": [3, 1, 2],
"a": {"b": 2, "a": 1}
}After Sort keys
{
"a": {
"a": 1,
"b": 2
},
"items": [
3,
1,
2
],
"z": 0
}Sort keys alphabetises the members of every object, working from the deepest objects outward, and then writes the result with the selected indent. Numeric-looking names are compared naturally and case is handled without the crude rule that places every capital letter before every lowercase one. Arrays are not sorted, because their order is part of the data: changing item zero into item five can change the meaning of an API response.
Sorting is helpful when two producers emit the same fields in different orders, when a configuration has grown unevenly, or before a human review. Duplicate names are not silently collapsed; they stay together in their original relative order. If you only want readable spacing and wish to preserve the exact member order, choose Format instead.
Repair broken input before formatting it
A formatter needs a trustworthy structure, so Format, Minify and Sort keys refuse invalid input. Code view underlines every syntax problem the parser can locate, and the status bar changes to Invalid JSON. Repair is a separate, visible operation for text that is recognisably close to JSON. It can remove comments and trailing commas, quote bare keys, convert single-quoted strings and Python literals, unwrap one JSON Markdown fence, and close several kinds of truncated ending.
Repair never happens as a side effect of Format. It reports the categories it changed, keeps the result as one undoable edit, and refuses prose whose intended document would require guessing. The Repair guide gives worked examples and the boundaries of that operation, while its tidy note covers the three valid-document rewrites.
Large numbers remain exact text
Input
{"id":12345678901234567890}Format
{
"id": 12345678901234567890
}JSON.parse
12345678901234567000Many formatters take a shortcut through JSON.parse and JSON.stringify. That route turns numbers into JavaScript doubles, which cannot represent every integer beyond 9,007,199,254,740,991 and can shorten long decimals. This formatter works from the parsed syntax tree but copies each number token from the original source. A database id with nineteen digits, exponential notation such as 1e400, negative zero and a deliberately written 1.0 all survive unchanged.
The same source-preserving path protects quoted keys and string escapes. Formatting therefore does not delete duplicate members, move integer-like keys ahead of their neighbours, or rewrite a character merely because JSON permits a second spelling for it. Sort keys is the only one of the three layout actions that deliberately moves object members, and its label says so before you press it.
Large files stay in the browser
The parser and formatter run locally; there is no processing API behind the page. Open and drag-and-drop read a file on your machine, while From URL asks the named site directly from your browser and stops a response above 64 MB. Structural Tree and Table views ask before building a document above 10 MB because parsing it can pause the page, but Code view and the text transforms are not an upload service with a hidden account limit.
Browser storage is smaller than browser memory. When a document is too large for this tab to preserve across reloads, the status bar marks it not saved instead of pretending persistence succeeded; the text remains available in the open page for you to save explicitly. Once the application itself has loaded, its formatter has no network dependency.