Code Minifier
Strip comments and unnecessary whitespace from JavaScript, CSS, HTML and SQL.
Code Minifier
Remove whitespace and comments to reduce file size.
Whitespace and comment removal only — this is not a compiler. It does not rename variables or tree-shake, and it never edits the inside of strings, template literals or regular expressions. Line breaks are kept so semicolon-free JavaScript keeps working.
What Code Minifier does
Minification here means removing what a machine does not need to read: comments, indentation and line breaks. That is enough to make a snippet compact for embedding in a template, a data attribute or a one-line command.
It is deliberately conservative. String literals, template literals and regular expressions are left untouched, because a minifier that edits inside a string silently breaks code.
- Remove comments and collapse whitespace in JavaScript, CSS, HTML and SQL
- Leave the contents of strings, templates and regular expressions unmodified
- Report the size before and after, and the percentage saved
How to use Code Minifier
- 1
Choose the language
Pick JavaScript, CSS, HTML or SQL. The rules for comments and whitespace differ for each.
- 2
Paste your code
Paste the snippet you want to compact.
- 3
Minify
The output pane shows the compacted code along with the size comparison.
- 4
Copy the result
Copy the output and test it before shipping it.
Limits and known behaviour
- This is not a compiler. It does not rename variables, remove dead code, evaluate constants or bundle modules, so it will not match the output of a production minifier such as Terser or esbuild.
- It does not parse your code into a syntax tree, so it cannot verify that the input was valid to begin with. Invalid input produces invalid output.
- JavaScript that depends on automatic semicolon insertion across line breaks can change meaning when lines are joined. Use explicit semicolons.
- For a real build pipeline, use your bundler. This tool exists for one-off snippets, not for production assets.
- HTML minification is whitespace and comment removal only; it does not rewrite attributes or remove optional tags.
Privacy and data handling
Runs entirely in your browser
- Your input is processed by JavaScript running in this page. The tool sends no request anywhere, so nothing you paste is transmitted or logged by this site.
- Nothing is saved between visits. Closing or reloading the tab discards whatever is in the fields.
Site-wide data handling, including analytics and advertising, is described in the privacy policy.
Frequently asked questions
Why is my saving smaller than a production minifier's?
Because most of a production minifier's saving comes from renaming identifiers and removing unreachable code, neither of which this tool does. Whitespace and comments are the smaller share.
Is the output safe to ship?
Test it first. The transformation is conservative and avoids editing inside strings, but it does not parse the language, so unusual code can still be affected. For production assets, minify as part of your build.
Can it reverse the process?
Not here. Use the code formatter for SQL, HTML and CSS.