Code Minifier

Minify JavaScript, CSS, HTML and JSON code to reduce file size.

Input
Output

                        

About Code Minifier

Code minification removes unnecessary characters from code to reduce file size. Perfect for production deployments.

Common Use Cases:

  • Reducing file sizes for production
  • Optimizing website performance
  • Preparing code for deployment
  • Bandwidth optimization

Developers: see the CI/CD & pipeline guide. More tutorials: guides hub · by Nalla.

Code minification, what gets removed and what stays

Minification removes characters that are meaningful to developers but irrelevant to parsers: whitespace (spaces, tabs, newlines), comments, and redundant delimiters. The result is functionally identical to the source but as small as possible. For JavaScript, CSS, and HTML, smaller files mean faster page loads, bytes that don't travel over the network are bytes that don't slow down the browser. A 40KB formatted JavaScript file typically minifies to 18–25KB, with no change in behaviour.

Basic minification (what this tool does) removes whitespace and comments. Advanced minification, done by tools like Terser for JavaScript, also shortens variable names: userAuthentication becomes a, and complex expressions can be inlined or eliminated if a compiler proves they're unreachable. Basic minification is safe to apply to any code; advanced renaming requires a proper build pipeline because it can break code that relies on string-based reflection or property names.

What is removedWhat staysNotes
Whitespace between tokensRequired whitespace (between keywords)Safe to remove
Line comments (//)Licence headers (/*!.*/)This tool removes all comments
Block comments (/* */)String literals (whitespace preserved)Safe to remove
Trailing semicolonsStructural semicolonsDepends on language

Where minification fits in a workflow

For projects with a build pipeline (webpack, Vite, Parcel, esbuild), minification happens automatically at build time, you don't need to manually minify. This tool is useful for: quickly minifying a one-off script or snippet you're inlining directly in HTML; testing what a minified version of a file looks like before setting up a build pipeline; reducing the size of a CSS override you're embedding in an email template; or compacting a JSON config file for an embedded device with limited storage.

Related: JavaScript formatter (restore readability), CSS formatter, JSON formatter.

Frequently Asked Questions

Minification typically reduces CSS and JavaScript file sizes by 20–50%, and when combined with gzip or Brotli compression on the web server, the transferred bytes can be reduced by 60–80% compared to unminified, uncompressed files. For a site with 500 KB of CSS and JS, this can save 300–400 KB per page load, a meaningful improvement on mobile connections.

The auto-detection logic checks the first non-whitespace character and structure: if it starts with { or [ it tries JSON parsing; if it starts with < it treats it as HTML/XML; if it contains { with : or ; it treats it as CSS; otherwise it treats it as JavaScript. The output badge shows you which type was detected so you can verify it matched your intent.

Minification removes unnecessary whitespace and comments to reduce file size while keeping the code functionally identical and still readable if formatted. Obfuscation goes further, it renames variables to meaningless single letters, restructures logic, and inserts confusing patterns to make reverse-engineering harder. Obfuscation provides some IP protection but adds complexity and is not needed for typical web performance optimization.