Back to Tools

Code Minifier

Compress and minify JS, CSS, and HTML files to save space.

Input Data

Shrink code by removing comments and whitespace

Code Minifier compresses JavaScript, CSS and HTML by deleting comments and collapsing the spaces, tabs and line breaks that humans need but browsers do not. Smaller files download faster, which matters for page speed on slow connections and for snippets that must fit into a length-limited field. The tool works in the browser page and gives you the before and after sizes so you can see what was saved.

Minifying a snippet

  1. Paste your formatted code into the Input Data box. Sample loads a short CSS rule, and Clear empties the box.
  2. Press Process Now. If the box is empty you get an error asking for code.
  3. Read the summary row: Original size, Minified size and Saved percentage. The sizes are counts of characters.
  4. Use Copy to grab the compressed text or Download to save it as result.txt.

There is no language selector. The same set of rules is applied to whatever you paste.

What it removes

  • Block comments between /* and */.
  • Line comments starting with // when they end with a line break.
  • Spaces around braces, colons, semicolons, commas, greater-than signs and opening square brackets.
  • Line breaks and tabs, which become single spaces, followed by a final collapse of repeated spaces.

Good uses

  • Compressing a small CSS block for an inline style tag.
  • Shrinking a bookmarklet or embed snippet to fit a character limit.
  • Measuring roughly how much whitespace and commenting a stylesheet carries.
  • Preparing a quick one-line version of an HTML fragment for a template string.

Read this before deploying

This is a lightweight text-based minifier and does not parse your code, rename variables or drop the final semicolon in a rule. That has consequences. Because line breaks turn into spaces, JavaScript that relies on automatic semicolon insertion, meaning statements without semicolons, can break. A double slash inside a string or URL followed by a line break may be mistaken for a comment, which is a known risk noted in the tool's own code. Whitespace around a greater-than sign is removed in HTML too, which can join inline text that needed a space. Always test the result, and use a full build-step minifier for production bundles.

Related Articles

Related Tools





Frequently Asked Questions

Does the minifier support JavaScript, CSS and HTML?
It is intended for all three, but uses one shared set of text rules instead of a per-language parser. It works best on CSS and on JavaScript that ends every statement with a semicolon. HTML is compressed too, but may lose meaningful spaces between inline elements.
Why did my JavaScript stop working after minifying?
Line breaks are converted to spaces, so code that depends on automatic semicolon insertion can merge statements together. A double slash inside a string or URL can also be mistaken for a comment. Add explicit semicolons and review strings, or use a build-tool minifier.
What does the Saved percentage mean?
It compares the character length of your trimmed input with the minified output and shows the reduction, to two decimal places. The Original and Minified figures are character counts, which for plain ASCII text roughly equal bytes.
Does it rename variables or shorten code the way build tools do?
No. It only removes comments and unnecessary whitespace. It does not rename identifiers, drop unused code or remove the last semicolon in a CSS rule, so savings will be smaller than those from a full minifier such as those in bundlers.
Can I undo the minification?
The original spacing and comments cannot be restored, because they are deleted. You can make the code readable again with the Code Beautifier, but comments will stay lost. Keep your source file and treat the minified text as an output.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.