Code Minifier
Shrink JavaScript, CSS or HTML before deploying. JavaScript is compressed with Terser, which can also shorten variable names and remove console calls, and syntax errors are reported with their line. CSS and HTML minification safely removes comments and extra whitespace while keeping strings, url() values and <pre>/<textarea> content intact.
How to use the Code Minifier
- Choose JavaScript, CSS or HTML.
- Paste your code or press Load example.
- Set options such as name mangling or comment removal.
- Press Minify and review the size reduction.
- Copy the result or download the .min file.
Features
- JavaScript compression and mangling with Terser
- Optional removal of console.* calls
- CSS minifier that keeps strings, url() and /*! licence */ comments
- HTML minifier that preserves <pre>, <textarea>, <script> and <style>
- Before/after size and percentage saved
Benefits
- Smaller files load faster for your visitors
- Quick one-off minification without a build tool
- All processing happens in your browser
Frequently asked questions
Is minified JavaScript safe to use in production?
Terser is the minifier used by most modern bundlers. Still, test the minified file, especially if your code relies on function names or eval.
Why is a space kept between some HTML elements?
A space between inline elements such as <b>a</b> <i>b</i> is visible on the page, so the minifier keeps one space there to avoid changing the layout.
Why does my CSS still contain a comment?
Comments that start with /*! are licence comments and are kept on purpose. Remove them manually if your licence allows it.
Related tools
- JSON Formatter — Beautify or minify JSON with 2-space, 4-space or tab indents, sort keys and browse it as a collapsible tree.
- JSON Validator — Check JSON syntax as you type, see the exact line and column of any error and get warnings for duplicate keys.
- XML Formatter — Pretty-print or minify XML with comments, CDATA and DOCTYPE support, plus a well-formedness check with error positions.
- HTML Formatter — Beautify HTML with your choice of indentation and line wrapping, including inline <script> and <style> blocks.
- CSS Formatter — Beautify minified CSS into readable rules with custom indentation, brace style and one selector per line.
- JavaScript Formatter — Beautify JavaScript with configurable indentation, brace style and line wrapping to make minified code readable.