Code Minifier

Minify JavaScript with Terser, and CSS and HTML, to make files smaller and pages faster. Shows the size saved. Runs in your browser.

Runs in your browserNo sign-upWorks offline
Ctrl+Enter to run
Input121 characters
Output
✓ ReadySample content shown

What the Code Minifier does

The Code Minifier makes JavaScript, CSS and HTML smaller by removing comments, spaces and line breaks that browsers do not need. JavaScript goes through Terser, the minifier used by most modern build tools, which can also shorten variable names safely. CSS minifying keeps strings and licence comments, and HTML minifying leaves <pre>, <textarea> and scripts untouched so nothing breaks. The size before and after is shown.

How to use it

  1. Choose JavaScript, CSS or HTML.
  2. Paste your code on the left.
  3. For JavaScript, choose whether to shorten variable names.
  4. Copy or download the minified code.

Example

The sample GST function shrinks from 167 to 97 bytes, 42% smaller: comments and spaces go, the parameter names become single letters, and 1000 is written as 1e3. The sample CSS goes from 162 to 117 bytes.

When to minify

Minified files download faster, especially on mobile data, and most build tools such as Vite or webpack do this automatically. Use this tool for a quick one-off: a snippet for a CMS, a script for an email template, or checking how much a file could shrink.

Keep the original readable file for editing. Minified code is hard to read and debug, and comments starting with /*! or containing @license are kept so licence notices are not lost.

Questions people ask

Is my code or data uploaded?

No. Everything runs in your browser, so config files, queries, logs and keys stay on your device. That makes it safe to use with work data.

Can minifying break my code?

Terser is careful, but code that relies on function names, such as some reflection tricks, can change. Untick shortening names if in doubt, and test the result.

Does it support modern JavaScript?

Yes, including modules, classes, arrow functions and async code.

How do I format code instead?

Use the HTML Formatter, JSON Formatter or SQL Formatter to make code readable again.

Related tools