json

FormatValidateConvert

Start over?

This clears both panes. Unsaved changes in either document are lost.

Replace that document?

This writes the matches into the other pane. What is there now is lost.

Load JSON from a URL

Your browser fetches it directly — the request goes to that site, never to us.

    ↑ ↓ to move · Enter to run · Esc to close

    Keyboard shortcuts

    Send feedback

    Questions, bug reports and feature requests are all welcome. A bug report is easiest to act on with the shape of the document that caused it — never send anything confidential.

    Email us

    Contact page, in a new tab, so this page stays as it is.

    Settings

    Indent

    Format and Sort keys write it, and Tab in Code view types it.

    Code text size
    14 px

    Code view and generated code.

    Wrap long lines
    Left pane opens in
    Right pane opens in

    In a new tab and after New. A view you choose in a pane is still remembered.

    JSON Formatter

    On the left pane · one documentOn one document
    0
    0

    About the formatter

    JSON Formatter: format, beautify and minify JSON.

    Your document never leaves the browser.

    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

    1

    Before

    {"name":"Ada","tags":["JS","Go"]}
    2

    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

    1

    Input

    {"user":{"name":"Ada","active":true}}
    2

    4 spaces

    {
        "user": {
            "name": "Ada",
            "active": true
        }
    }
    3

    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

    1

    Before

    {
      "z": 0,
      "items": [3, 1, 2],
      "a": {"b": 2, "a": 1}
    }
    2

    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

    1

    Input

    {"id":12345678901234567890}
    2

    Format

    {
      "id": 12345678901234567890
    }
    3

    JSON.parse

    12345678901234567000

    Many 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.

    FAQ

    Frequently asked questions

    Didn’t find your answer?Write to us on the contact page →
    What is the difference between formatting and beautifying JSON?

    On this page they mean the same operation: adding line breaks, indentation and a space after each colon so the structure is easier to scan. The values, array order and object-key order stay as written. Choose the indent under Settings before you press Format if two spaces is not the style you need.

    Will formatting change a large number?

    No. The formatter writes number tokens directly from the source text instead of converting them to JavaScript numbers first. A 19-digit identifier, a long decimal, 1e400, -0 and 1.0 therefore keep the spelling and every digit you supplied.

    Can this formatter fix invalid JSON?

    Format deliberately refuses text that does not parse, because guessing during a whitespace operation could alter data. Use Repair first for common near-JSON such as comments, trailing commas, single quotes, bare keys, Markdown fences or a response cut off at the end; read its list of changes, then format the valid result.

    Does my JSON get sent to a server?

    No. Parsing and rewriting happen in JavaScript inside this tab, and a local file is read with the browser file API. After the page has loaded, formatting, minifying, sorting and repairing continue to work without a connection.