JSON Minifier

Minify JSON data

About JSON Minifier

JSON Minifier removes every space, tab, and line break outside strings and puts your JSON on one line. It validates the text with the browser's JSON.parse first, then copies your original characters, so values are never re-serialized: a 20-digit ID, 1.10, 1e21, and escapes stay exactly as written, and spaces inside strings are kept. A byte order mark at the start is removed. The line under the result gives the characters saved and the percentage. The page has no option to sort keys or change values, and it does its work in your browser.

Example

Formatted JSON on five lines becomes one; the two spaces inside the string stay.

Input

{
  "id": 12345678901234567890,
  "total": 1e21,
  "name": "a  b"
}

Minified output

{"id":12345678901234567890,"total":1e21,"name":"a  b"}

How to minify JSON

  1. 1Paste formatted JSON into "Input".
  2. 2Click "Minify".
  3. 3Take the single line from "Minified output"; the line below it says how many characters were saved.
  4. 4Click "Copy", or "Download" to save "minified.json".

Formats and limits

Input
JSON text; a leading byte order mark is removed
Output
One-line JSON, saved as minified.json
Kept as written
Every key, value, number, and escape, and the spaces inside strings
Saving shown
Characters saved and the percentage, counted in characters rather than bytes

Where your JSON is processed

Minification is a few lines of JavaScript in this page: your JSON is read and rewritten in the browser and never uploaded. When the page displays an error, Invalid JSON followed by the browser's reason, that message is reported to our error log with the tool name and your browser's name and version, cleaned of quoted passages, long numbers, and addresses.

Frequently asked questions

Will minifying change my data?

No. Only whitespace outside strings is removed. Keys, values, numbers, and escapes are copied character for character, so large IDs are not rounded, and two spaces inside a string value stay two spaces.

Does it tell me when the JSON is invalid?

Yes. A red Invalid JSON message with the browser's explanation appears and nothing new is produced. A result from an earlier run stays in the output box, so read the message before copying.

Does it also sort or clean my JSON?

No. It keeps key order, duplicate keys, and values as they are. To sort keys or pick an indentation, use JSON Formatter, which offers sorting and three indent choices.