ToolsWise.com

Code Minifier

JavaScript

Input Code

Minified Output

Free Code Minifier

Minify JavaScript, CSS, and HTML instantly in your browser. Strip whitespace and comments, shrink your files, and see exactly how much you saved — no sign-up, nothing uploaded.

What is a code minifier?

A code minifier removes everything a browser does not need to execute your code — spaces, indentation, line breaks, and comments — to make the file as small as possible. For JavaScript, modern minifiers go further by renaming local variables and eliminating unreachable code, while keeping the program's behavior identical.

Smaller files download faster and use less bandwidth, which is why minification is a standard step before shipping web assets to production. This tool brings Terser, CSSO, and a safe HTML minifier together so you can compress any of the three without a build step.

Key Features

JavaScript Minification

Powered by Terser — drops whitespace, shortens local names, and removes dead code to produce a compact, runnable bundle.

CSS Minification

Uses CSSO for structural optimization: merges rules, collapses values, and strips comments without changing how the page renders.

Safe HTML Minification

Collapses whitespace and removes comments while preserving the exact contents of pre, textarea, script, and style blocks.

Live Savings Readout

See the original size, the minified size, and the percentage saved so you know exactly how much smaller the output is.

Syntax-Aware Errors

If your JavaScript has a syntax error, the tool surfaces the message inline instead of producing broken output.

100% Client-Side

Every byte is minified in your browser. Nothing is uploaded to a server or stored anywhere.

How to Minify Code

1

Choose your language

Pick JavaScript, CSS, or HTML. The input area is pre-filled with a readable sample you can replace.

2

Paste your code

Drop in the code you want to shrink. Switching language re-runs minification automatically.

3

Click Minify

JavaScript minification runs asynchronously with Terser; CSS and HTML run instantly.

4

Copy or download

Grab the minified result with one click, or download it as a .min.js, .min.css, or .min.html file.

Common Use Cases

  • Faster page loads: Ship smaller JS and CSS so browsers download and parse less, improving Core Web Vitals.
  • Inline snippets: Compress small scripts or styles before pasting them into a CMS, email template, or landing page.
  • Bandwidth savings: Reduce transfer size for high-traffic assets where every kilobyte multiplies across requests.
  • Quick one-off builds: Minify a file without spinning up a bundler or build pipeline for a single change.
  • Learning and inspection: See how a minifier rewrites your code and compare original versus optimized output side by side.

Frequently Asked Questions

What does minifying code actually do?

Minification removes characters that are not needed to run the code — whitespace, line breaks, and comments — and, for JavaScript, can also shorten local variable names and remove dead code. The result behaves the same but is smaller and faster to download.

Which minifiers power this tool?

JavaScript is minified with Terser, CSS with CSSO, and HTML with a built-in safe minifier. Terser and CSSO are industry-standard libraries that run entirely in your browser.

Is HTML minification safe for my markup?

Yes. The HTML minifier removes regular comments and collapses whitespace between tags, but it preserves the exact contents of pre, textarea, script, and style blocks and keeps IE conditional comments intact, so significant content is never corrupted.

Why did my JavaScript fail to minify?

Terser parses your code before minifying it, so a syntax error will stop the process. The tool shows the parser's error message inline so you can find and fix the problem.

Is my code uploaded anywhere?

No. All minification happens locally in your browser using client-side libraries. Your code is never sent to a server or stored.

How much smaller will my files get?

It depends on the source, but the tool shows the exact savings for your input — original size, minified size, and the percentage reduction. Verbose, well-commented code typically shrinks the most.