Back to Tools

JSON Minifier

Remove all whitespace and comments for high-performance production JSON

0
0
0%
Raw JSON

Shrink formatted JSON into a single compact line

Pretty-printed JSON is pleasant to read, but every indent, space and line break adds characters that a parser ignores. The JSON Minifier takes an indented document and rewrites it as one continuous line with all of that formatting removed. The data itself is unchanged: same keys, same values, same order. Only the layout shrinks, which helps when you are embedding a payload in a config value, a query string, a test fixture or a source file where one line is easier to handle.

Minifying a document, step by step

  1. Paste your formatted JSON into the Raw JSON box, or press Load Sample to see an indented example.
  2. Watch the Original counter in the header update as you type. It shows the length of your input in characters.
  3. Press Minify JSON Now.
  4. Read the Minified Result panel. The Minified counter shows the new length and Savings shows the percentage removed.
  5. Press Copy Minified to put the single-line text on your clipboard, or Clear to start over.

How it works and what it checks

The page parses your text with the browser's own JSON parser and then serializes the resulting value without any spacing. Because it has to parse first, the tool doubles as a quick syntax check: if the input is not valid JSON, an Invalid JSON message appears with the parser's explanation instead of producing output. The work happens in your browser tab through JavaScript, and there is no separate download button, so the copy button is how you take the result away.

Where minified JSON is useful

  • Pasting a sample response into an environment variable, a CI secret field or a single-line configuration setting.
  • Building a compact body for a curl command or an API request that you will send from a terminal.
  • Reducing the size of a JSON blob before you store it in a text column or a cache key.
  • Comparing two documents by eye after both have been reduced to the same layout.

Things worth knowing

  • Standard JSON does not allow comments or trailing commas. Input containing them will be rejected rather than silently cleaned, so remove them first.
  • The savings figure compares the trimmed input with the output, so already-compact JSON will show a low or zero percentage.
  • Numbers and strings are re-serialized by the parser. Very large integers can lose precision, and a number written as 1.0 comes back as 1.
  • Unicode escapes inside strings may be output as the actual characters, which is still equivalent JSON.
  • Minifying is not compression in the gzip sense. Servers that compress responses will still gain a little from removing whitespace, but do not expect the savings percentage to match transfer size.

Related Tools


Frequently Asked Questions

Does minifying change my JSON data?
No. The tool parses the document and writes it back without whitespace, so keys, values, nesting and array order stay the same. The only visible differences are removed spaces and line breaks, plus normal re-serialization of numbers, such as 1.0 becoming 1.
Can it remove comments from my JSON?
No. Comments are not part of the JSON standard, and the parser used here rejects them. If your input contains comments or trailing commas, you will get an Invalid JSON message, and you will need to delete them yourself before minifying.
What do the Original, Minified and Savings numbers mean?
Original is the character count of what you pasted, Minified is the character count of the result, and Savings is the percentage of characters removed. They count characters, not bytes, so multi-byte characters are counted once each.
Why did I get an Invalid JSON error?
The input failed to parse. Common causes are single quotes around strings, unquoted keys, a trailing comma after the last item, or a missing bracket. The message shows the parser's own description of the problem so you can locate and correct it.
Is there a way to download the minified file?
This tool only offers a Copy Minified button. Press it, then paste the text into your editor or a new file and save it with a .json extension. The output is a single line, so it pastes cleanly anywhere.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.