Skip to content
OddsockLocal
Local
Source text
{
  "color": "red",
  "count": 2
}
1 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste JSON into Source text. Pretty-printed or compact both parse.
  2. There is no indent control. The result is the compact line.
  3. Compare the length of the result with the length of the paste.
  4. Copy the one-line JSON.

What is JSON minifier?

Whitespace in JSON is for readers. On the wire it is cost. JSON minifier parses the document and writes it back with no space after colons or commas and no newlines. The result is one line. Compare its length with the source you pasted. A two-space pretty print of {"color":"red","count":2} is 34 bytes. The minified line is 25 bytes. Nine bytes were indentation and the spaces that sit beside colons.

Read more

If you paste a string that is already compact, the result matches the paste and the saving is zero. The page does not sort keys and does not change numbers or strings. A syntax error is reported with a line and column, and no compact line is produced. The formatter's indent 0 writes this same string. Open the minifier when the question is the size.

Use cases

  • A frontend engineer minifies a config before inlining it, and records 25 bytes instead of 34.
  • An API client compares a logged pretty body with the minified form to see what whitespace cost.
  • A fixture stored pretty in git is minified for a size check without changing key order.
  • Someone shipping a small embedded payload confirms the compact line still parses.
  • A review of a generated file uses the minified length as the number to put in a budget note.

Nine bytes of whitespace

Paste the pretty form, indent 2: { "color": "red", "count": 2 }

{"color":"red","count":2} The pretty paste is 34 bytes. The result is 25 bytes. The difference is 9 bytes.

Why use Oddsock

The compact line is the payload, and the 34-to-25 comparison tells you what the indent was costing on this object.

Related tools

Using this tool

The pretty form has newlines, two-space indents, and a space after each colon. Removing them takes {"color":"red","count":2} from 34 bytes to 25.