How to use the code minifier
Stripping indentation, blank lines and comments from CSS and JavaScript makes the file smaller and quicker to download. This tool offers two strengths. Tidy whitespace trims each line, collapses repeated spaces and drops empty lines while keeping the line breaks, so the result is still readable. Collapse to one line removes the line breaks too and also deletes spaces around braces, semicolons, commas, colons and parentheses.
Deleting whitespace blindly would break the code, so the input is scanned first. Single-quoted, double-quoted and backtick strings are lifted out whole and their contents are never touched. Comments that start with two slashes or slash-asterisk are removed, while the double slash inside a protocol such as http:// is recognised and left alone. Regular expression literals are detected in the usual positions, after an equals sign, an opening parenthesis or a comma, and their inner spaces are preserved.
The limits are worth knowing. Collapsing to one line can change the meaning of JavaScript written without semicolons, because two statements end up on the same line, so it is safest on CSS. The tool never renames variables or rewrites syntax, and HTML markup is out of scope. Everything is processed inside your browser.
Frequently Asked Questions
No. Quoted and backtick strings are lifted out before whitespace is touched, so everything inside them, including line breaks, stays exactly as written.
Code written without semicolons relies on line breaks to end statements, and those disappear when everything is joined. Add semicolons, or use the tidy button that keeps line breaks.
No. This tool only handles whitespace and comments. Renaming and syntax rewriting belong to a full build-step minifier.