Minify CSS and JS

Take the comments and slack whitespace out of a stylesheet or script for a quick size saving.

or drop them here · files stay on your device
We count formats and sizes. Filenames stay private unless you opt in.

Processed on this device
  • Runs on your device
  • No sign-up or watermark
  • No fixed file size cap

The short answer

To minify CSS or JavaScript without uploading it, choose one or more .css or .js files and run the minifier. It removes /* block comments */, blank lines and surplus spaces in your browser, leaving strings untouched. It never renames variables, so a bundler such as esbuild will shrink files further.

How to minify CSS and JS files in your browser

  1. STEP 1

    Choose CSS or JS files

    Select one or more .css or .js files. The source is read on your device and nothing is sent out.

  2. STEP 2

    Run the minifier

    There are no settings: comments and surplus whitespace are removed in one pass.

  3. STEP 3

    Check the preview

    Look over any regular expressions in JavaScript, which the pass does not parse, before you ship the file.

  4. STEP 4

    Download the result

    Files save as name.min.css or name.min.js, with the percentage saved shown in the report.

What minification does

Minification removes what the browser does not need to run the code: comments, indentation and spacing. Full minifiers such as Terser or esbuild go further, parsing the code to shorten variable names and drop unreachable branches, which needs a real parser for each language.

A whitespace-only pass is quicker to reason about but cruder. It is a reasonable fit for a small stylesheet or snippet you want to inline, not a replacement for a build step on a production bundle.

What survives, and what does not

The tool reads the file character by character. It removes everything between /* and */, collapses each run of whitespace to one space, and drops it entirely beside { } ; and , (plus > in CSS, and ( ) = in JavaScript). Strings and template literals are copied exactly, and CSS keeps the space in descendant selectors. In JavaScript every line break is kept, so code that relies on automatic semicolon insertion keeps working, and // line comments are left alone.

What you keep

Line breaks between JavaScript statements, so code without semicolons still runs

// line comments and variable names, untouched

Text inside strings and template literals, exactly as written

The space in CSS descendant selectors such as .menu :hover

Statement order and logic

What you lose

Licence comments in /*! ... */ form are removed along with all other block comments

Some JavaScript savings, since line breaks and // comments are kept for safety

No variable renaming or dead-code removal, so savings are smaller than a real minifier

Honest limits are published on every tool page. If a tool cannot do something well, it says so here rather than letting you find out after the download.

Minify CSS and JS at a glance

InputCSS, JS
OutputMinified CSS or JS
MethodWhitespace and block-comment removal that skips strings
BatchYes, several files at once
Runs onYour device, in the browser
Works offlineAfter the first use

If something goes wrong

A regular expression broke after minifying

Regex literals are not parsed, so one containing a quote mark or /* can be read as a string or comment. Build that pattern with new RegExp() in the source, or use esbuild for that file.

The JavaScript file barely got smaller

Line breaks and // comments are kept in JavaScript so the code behaves the same. A parser-based minifier such as esbuild or Terser removes those safely and renames variables too.

The licence header disappeared

All /* */ comments are removed, including /*! licence */ blocks. Paste the header back at the top of the minified file if you need it.

Minify CSS and JS questions

How do I minify CSS without uploading the file?

Choose the .css file here and run the minifier. It works in your browser tab, so proprietary stylesheets and unreleased code are not sent anywhere.

Does it rename variables like Terser?

No. It only removes block comments and whitespace. For variable renaming and tree-shaking, use a bundler such as esbuild, Terser or cssnano.

Is it safe on any JavaScript?

Mostly. Strings and template literals are copied untouched and line breaks are kept, but regular expressions are not parsed, so a regex containing /* or a quote mark can confuse it. Check the preview before shipping.

How much smaller will my file get?

It depends on how heavily commented and indented the source is. The report shows the exact saving; already-minified files will barely change.

Can I minify several files at once?

Yes. Select them together and they come back as a ZIP, each with .min added before the extension.

One of 153 file tools and planned additions. Built and tested by Arin Prajapati, last checked against the code on . canonical: https://damnfiles.com/minify-css-js
Analytics preferences

Help us understand which tools and file types people use. File contents always stay on your device.

Filename sharing is optional and off by default. Names can contain personal information. Changes apply to future events; disabling sharing does not delete earlier records.

Read our privacy policy