Code Minifier

Minify JavaScript, CSS and HTML online with Terser, csso and html-minifier — free code minifier.

About

About the Code Minifier

Minifies JavaScript, CSS or HTML using the exact same real minifiers popular build tools use — Terser for JavaScript, csso for CSS and html-minifier-terser for HTML — loaded from this site and run entirely in your browser.

Developers use it to shrink a snippet without setting up a build tool, while performance-conscious site owners use it to check how much smaller a file gets. It's one of many free developer tools on Toolapt, and like every tool here, it's free to use with no sign-up and no limit on how many times you run it.

Choose what to view about this tool

Guide

Using the Code Minifier

  1. 1

    Step 1

    Choose the language of the code you're minifying.

  2. 2

    Step 2

    Paste your code into the Input box.

  3. 3

    Step 3

    Click "Minify" to produce the compressed result.

  4. 4

    Step 4

    Copy the minified output, or Clear to start over.

  • Uses real production-grade minifiers — Terser, csso and html-minifier-terser — not a rough approximation
  • Shows size-reduction stats after each run
  • Loads the appropriate minifier from this site only the first time you use that language
  • Your code is minified locally and never uploaded to a server
  • Free to use, with no limit on how many times you run it
  • Fully responsive, so it works just as well on a phone as on a desktop

Developers

Developers use the Code Minifier for shrinking a snippet before pasting it somewhere space-constrained, without setting up a build tool.

Students learning about bundlers

Students learning about bundlers use the Code Minifier for seeing exactly what real minification looks like on their own code.

Anyone without a build pipeline

Anyone without a build pipeline uses the Code Minifier for compressing a one-off script or stylesheet by hand.

Performance-conscious site owners

Performance-conscious site owners use the Code Minifier for checking how much smaller a file gets before deciding whether it's worth automating.

Examples

Code Minifier examples

3 worked examples

01

CSS shrunk with csso

Minifying a nicely formatted "body { color: red; margin: 0; }" rule with csso produces body{color:red;margin:0}, with whitespace and line breaks removed.

02

JavaScript shrunk with Terser

Minifying "function add(a, b) { return a + b; }" with Terser produces function add(a,b){return a+b}, since Terser also shortens code where it's safe to.

03

HTML shrunk with html-minifier-terser

Minifying a multi-line <div><p>Hi</p></div> block with html-minifier-terser produces <div><p>Hi</p></div> on one line, with indentation and line breaks stripped.

FAQ

Frequently asked questions

Quick answers to common questions about the Code Minifier.

What does the Code Minifier do?

It minifies JavaScript, CSS or HTML using the same real minifiers — Terser, csso and html-minifier-terser — that popular build tools use.

Is the Code Minifier free to use?

Yes. It's free, with no sign-up, no watermark and no limit on how many times you use it.

Is my code safe when I use this tool?

Yes. Your code is minified entirely on your own device. The real minifier library for your chosen language loads from this site the first time you use it, but your code itself is never uploaded.

Which languages does it support?

JavaScript (via Terser), CSS (via csso) and HTML (via html-minifier-terser).

How much smaller will my file get?

It depends on the code — the result shows exact before/after size stats after each run so you can see the real reduction.

Is minified code the same as obfuscated code?

No. Minification removes whitespace and shortens names where safe to do so; it isn't designed to hide logic the way dedicated obfuscation tools are.

Can I use the Code Minifier on my phone?

Yes. The page is fully responsive and works on mobile, tablet and desktop browsers alike.

Does the Code Minifier have any limitations?

It minifies one language at a time; mixed-language files (like HTML with embedded JavaScript) are minified as HTML, not split apart.

Still have a question? Contact us

Report a problem

Code Minifier

What went wrong?
    or paste a screenshot