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 Minify

    On the left pane · one documentOn one document
    0
    0

    About JSON Minify

    JSON Minify: remove whitespace from JSON.

    Your document never leaves the browser.

    Put a JSON document on one line with a single press, without sending it away. For readable indentation and sorting, use the JSON Formatter; for input that will not parse, use JSON Repair; for the complete workspace, open the JSON editor.

    What JSON minifying removes

    1

    Before

    {
      "id": 12345678901234567890,
      "label": "two  spaces",
      "price": 1.0
    }
    2

    Minified

    {"id":12345678901234567890,"label":"two  spaces","price":1.0}

    JSON grammar allows whitespace between tokens and gives it no meaning. The spaces, tabs, line feeds and carriage returns around brackets, braces, commas and colons are there for people reading the file. Minifying deletes every one of them and leaves the tokens in the same order, so the whole document sits on one line. A conforming parser reads the minified text into exactly the same data as the indented original.

    Paste or open JSON on this page, then press Minify under Transform in the pane toolbar, or find Minify in the command palette. The rewrite is one step in the undo history. Minify needs a document that parses, because stripping whitespace from broken text would hide where it is broken; when the status bar says Invalid JSON, the button is unavailable and points you to Repair, which fixes common near-JSON first and names each change.

    Whitespace inside a string is part of its value, so it stays. In the example above the label keeps both of its spaces, and an escaped newline written as a backslash and an n stays as those two characters instead of turning into a real line break. Only the gaps between tokens go. The same rule protects tabs and spaces in keys, which JSON allows even though they are rare.

    Big numbers stay exactly as written

    The quickest way to write a minifier in JavaScript is to parse the text and stringify it again, and many online tools do exactly that. The round trip converts every number to a double-precision float, which holds integers exactly only up to 9,007,199,254,740,991. The twenty-digit id in the example would come back as 12345678901234567000, which identifies a different record, and nothing would warn you. The same round trip rewrites 1.0 as 1, keeps only the last of any duplicate keys and moves integer-like keys to the front of their object.

    This minifier never makes that round trip. It parses the text into a syntax tree and writes each number, string and key back out as the characters you supplied. A nineteen-digit database id, a long decimal price, 1e400, -0 and 1.0 all survive, and so do escape sequences inside strings: an escaped slash or a Unicode escape keeps its spelling instead of being decoded into a second, equivalent form. Duplicate keys stay where they were, in their original order.

    That makes the output safe to diff and safe to hand to a system that reads 64-bit integers natively. It also makes Minify and Format exact inverses for layout. Minify, format, then minify again, and you get back byte for byte the text the first Minify produced.

    JSON minify and gzip solve different problems

    Minifying and compressing both make JSON smaller, but at different layers. Minify produces text that is still JSON: any parser reads it, you can paste it into a request body or a configuration field, and it stays small wherever it is stored. Gzip and Brotli are encodings applied in transit, usually by the web server, and the receiver has to decode them before a parser sees anything.

    Compression is very good at squeezing out repeated whitespace, so the saving from minifying shrinks once a response is gzipped. Indentation that makes up a large share of a file on disk may cost only a few percent after compression. Minify still pays wherever compression does not reach: a value stored in a database column or in browser storage, an environment variable, a message on a queue with a size limit, a fixture committed to a repository, or JSON embedded as a string inside another document. The usual answer is both: minify what you store and send, and let the server compress the wire.

    The status bar shows the size of the document in UTF-8 bytes, so press Minify and read the new figure to see what the whitespace was costing. Undo, and the indented version returns with the size it had before.

    Format JSON again when people need to read it

    Minified JSON is written for machines. When a person needs to review it, debug a response or compare two versions, turn it back into indented text. The JSON Formatter page opens the same editor with two panes side by side, and offers Format with two, three or four spaces or a tab, plus Sort keys for objects whose members arrive in different orders. Neither layout touches a token, so you can switch between them as often as you like.

    You do not have to leave this page for that. Format sits beside Minify under Transform, and Tree view reads a single-line document as easily as an indented one, because it draws the structure rather than the text. When you convert YAML, XML or CSV on the Convert page, its Minify option writes the JSON result on one line in the first place.

    Format and beautify JSON again with the indent you choose.

    Minify a large file without uploading it

    Minifying runs in JavaScript inside this tab, on a parser the site ships with the page. Open a file from disk or drag it onto the editor and it is read through the browser, not sent anywhere; From URL fetches the address you give it straight from your browser. API keys, customer records and unreleased configuration therefore stay on your own machine, and Minify keeps working once the page has loaded, connected or not.

    Large documents follow the same path. Code view and the text transforms work on the whole file. When a document is too large for the browser to keep across a reload, the status bar marks it as not saved instead of claiming otherwise, and the minified text stays in the open tab for you to copy or save.

    FAQ

    Frequently asked questions

    Didn’t find your answer?Write to us on the contact page →
    What does JSON Minify remove?

    Only the spaces, tabs and line breaks that sit between tokens, outside any string. Keys, values, the order of members and array items, and the spelling of every number and escape are all left alone, so the minified text holds exactly the data the indented text held.

    Will minifying JSON change a big number?

    No. Numbers are copied from your text character for character and never pass through a JavaScript number, so an id longer than sixteen digits, 1e400 or a trailing .0 comes out spelled the way it went in.

    Is minified JSON the same as gzipped JSON?

    No. Minified JSON is still plain JSON text that any parser reads directly. Gzip is a binary encoding, normally added by a web server for the trip over the network and removed by the receiver before parsing. They combine well: minify what you store, and let the server compress what it sends.

    Is my JSON uploaded to be minified?

    No. The minifier runs in this browser tab on code that came with the page, and a file you open is read from your own disk. Nothing is transmitted, and after the first load the page minifies without a connection.