⌘K

Developer

Minification

Minification removes every byte a machine does not need — whitespace, line breaks, comments and long names — from code or data without changing what it does.

Updated 12 Aug 2026

Smaller output, identical behaviour

Source code and formatted data contain a lot of characters that exist purely for human readers. Minification strips them: indentation, newlines, comments and — in JavaScript — long local variable names, which a minifier can safely shorten because nothing outside the function can see them.

Minification is not compression

MinificationCompression (gzip/brotli)
Works onSource textAny bytes
ResultStill valid, readable-ish codeBinary, must be decompressed
AppliedAt build timeIn transit by the server
Combine?Yes — minify first, then compressYes

The two stack: minifying before gzip typically yields a smaller payload than either alone, because the minifier removes patterns the compressor would otherwise have to encode.

When to minify JSON

  • API responses and anything sent over the network — always
  • Files committed to version control — no, diffs become unreadable
  • Configuration a person edits — no, keep it formatted
  • Large payloads stored in a database column — usually yes

JSON Formatter

Switch between compact and readable output with one click.

Try JSON Formatter

Characteristics

  • Removes whitespace, newlines and comments
  • Preserves exact behaviour and, for data, exact values
  • Reversible for JSON, only partly reversible for code
  • Commonly paired with source maps for debugging

Common uses

  • Shrinking JavaScript and CSS bundles for production
  • Compacting API payloads
  • Reducing storage for logs and cached documents
  • Fitting data into size-limited fields or query strings

Advantages

  • Meaningfully smaller payloads and faster page loads
  • Compounds with gzip or brotli compression
  • No behavioural change when done by a correct tool
  • Automated as a build step, so it costs nothing ongoing

Limitations

  • Minified output is hard to read or debug without source maps
  • Produces unreadable diffs if committed to a repository
  • Gains are marginal for small files
  • Aggressive code minification can break reflection-based logic

Examples

The same object formatted and minified
{
  "id": 4821,
  "roles": ["admin", "editor"]
}

{"id":4821,"roles":["admin","editor"]}

Frequently asked questions

What is minification used for?

Reducing the size of code and data so pages load faster and payloads cost less to transfer.

Is minification the same as compression?

No. Minification rewrites the source; compression encodes bytes for transit. Use both.

Does minified JSON parse faster?

Slightly, but the real gain is a smaller download rather than parse speed.

Can minification be undone?

JSON can be beautified back exactly. Code can be reformatted, but original names and comments are gone.

Should I commit minified files?

No. Generate them at build time and keep readable sources in version control.

Related terms

All terms

Related tools

Related guides

All guides