HTML, CSS & JS Minifier

Free HTML, CSS and JS minifier: safely remove comments and extra whitespace from your code and see how many bytes you save. Runs in your browser.

Code type

Safe mode: only comments and extra whitespace are removed. JavaScript keeps its line breaks and is not renamed or rewritten, so it behaves exactly the same. For maximum compression use a build tool (Terser, esbuild). Always test the result before publishing.

Everything happens in your browser. Nothing is uploaded.

Smaller code files without breaking them

Comments, indentation and blank lines make code readable for people, and browsers do not need any of it. Removing them shrinks HTML, CSS and JavaScript files, which helps pages load a little faster, particularly on mobile connections. This minifier is deliberately cautious: it strips comments and surplus whitespace, but it never renames variables or rewrites logic, so the result behaves exactly like the original.

How to use it

  1. Pick the Code type: HTML, CSS or JavaScript.
  2. Paste into Your code.
  3. Press Minify. The Minified code box shows the result, and the status line reports the size before and after with the percentage saved.
  4. Use Copy or Download, and test the minified file before publishing it.

Example

This 88-character CSS rule, with a comment and indentation, /* Header */ .site-header { margin: 0 auto; padding: 16px 24px; color: #111827; } spread over several lines, becomes .site-header{margin:0 auto;padding:16px 24px;color:#111827} at 59 characters, about a third smaller. Spaces that matter, such as the one in 0 auto, stay. In JavaScript, a function written as function add(a, b) { return a + b; // total } over several lines keeps its line breaks but loses the comments and indentation.

What is protected

  • CSS: calc() expressions keep their required spaces, strings keep their content, and comments starting with /*! (licence notices) are kept.
  • JavaScript: strings, template literals and regular expressions are left untouched, and line breaks are preserved so automatic semicolon insertion cannot change meaning.
  • HTML: the content of <pre> is kept as is, inline style and script blocks are minified with the matching rules, and conditional comments survive.

Because it plays safe, typical savings are around 20–40 %. Build tools like Terser or esbuild go further by renaming and restructuring code; use those in a real build pipeline, and this tool for quick one-off jobs, snippets and themes edited by hand.

Shrinking images on the same page often saves far more than code; try Compress Image. Formatting JSON data instead of code? Use JSON Formatter.

Frequently asked questions

Can minified code break my site?

This mode is designed not to, but unusual code can still trip any minifier. Keep the original, and test the minified version before replacing it.

Why does the JavaScript still have line breaks?

Joining lines can change how JavaScript inserts semicolons. Keeping them is the safe choice; the comments and indentation are still removed.

Can it un-minify code?

No. It only removes whitespace. For readable code, your editor’s formatter or the original source is the way back.

Does it obfuscate code?

No. Names and logic stay readable; minification is about size, not secrecy.

Is my code uploaded?

No. It is processed in your browser only.