Code Minifier

Shrink your HTML, CSS, or JavaScript by stripping comments and whitespace — free and private.

Make CSS, JavaScript and HTML smaller, safely

Comments, indentation and line breaks make code readable for people but are dead weight for browsers. Minifying removes them so a stylesheet, script or page downloads faster. This minifier is deliberately careful: it reads your code character by character and never touches the inside of strings, template literals, regular expressions, <pre> blocks or textareas, so a URL like "https://example.com" or a regex with two slashes is not mistaken for a comment. It shows how many characters you saved.

How to minify code

  1. Choose CSS, JavaScript, or HTML.
  2. Paste your code into the box.
  3. Click Minify.
  4. Copy the compact output and check the size saved.

Features

  • Minifies CSS, JavaScript, and HTML.
  • Removes comments and unnecessary whitespace.
  • Shows characters and percentage saved.
  • Private and browser-based.
  • Free with no sign-up.

What is removed for each language

TypeRemovedLeft alone
CSSComments, line breaks, indentation, spaces around { } : ; , >, the last ; before }Text inside quotes, such as url("a b.png") and content: "→"
JavaScript// and /* */ comments, indentation, blank lines, repeated spacesStrings, template literals, regular expressions, and the line breaks between statements
HTMLComments (except <!--[if conditional ones), repeated whitespace, spaces around block tags<pre> and <textarea> content; the single space between inline words and tags; inline <script> and <style> are minified with the JS and CSS rules

Why line breaks stay in JavaScript

JavaScript lets you leave out semicolons; the line break then ends the statement. Joining such lines into one would break the code, so this minifier keeps one line break between statements. The result is a little larger than a full build tool would produce, but it is safe to paste into a live page. Variable names are not shortened.

Example

/* main button */
.btn {
    color: #ffffff;
    padding: 10px 18px;
}

becomes .btn{color:#ffffff;padding:10px 18px}, 37 characters instead of 70. The browser reads both in exactly the same way.

Before you publish minified code

  • Keep the original. Edit the readable version and minify a copy for the live site.
  • Test the page, especially buttons and forms that use the JavaScript.
  • Turn on server compression. Most hosts (Hostinger, cPanel, Cloudflare) can gzip or Brotli files, which saves another 60 to 80% on top of minifying.
  • For big projects, a build tool such as esbuild or Terser also shortens variable names and removes unused code.

Your privacy

Your code is minified by your own browser and is not uploaded, so private source code and API endpoints stay on your device.

Frequently asked questions

Is the minified code safe to run?

Yes. Strings, template literals and regular expressions are left untouched, and JavaScript keeps its line breaks between statements, so the code behaves exactly as before. Test important pages anyway.

Will it break a URL like https:// in my JavaScript?

No. The minifier knows when it is inside a string, so the // in a URL is not treated as a comment.

Does it rename variables?

No. Only comments and whitespace are removed. Build tools such as esbuild or Terser can also shorten names.

How much smaller will my file get?

It depends on how much commenting and indentation the code has; well-commented CSS often shrinks by 20 to 40%. Server gzip or Brotli compression saves more on top.

Can I turn minified code back into readable code?

Formatting can be restored with a code beautifier, but comments that were removed cannot come back. Keep your original file.

Is my code uploaded?

No. Minifying happens in your browser.

Related tools