Language
English English Vietnamese (Tiếng Việt) Vietnamese (Tiếng Việt) Chinese (简体中文) Chinese (简体中文) Portuguese (Brazil) (Português do Brasil) Portuguese (Brazil) (Português do Brasil) Spanish (Español) Spanish (Español) Indonesian (Bahasa Indonesia) Indonesian (Bahasa Indonesia)
Code Minifier

Code Minifier

Minify JavaScript, CSS, and HTML code to reduce file size with real-time compression stats and configurable options.

What Is Code Minifier?

Code Minifier is a browser-based tool that compresses JavaScript, CSS, and HTML code to reduce file size. It removes unnecessary characters like comments, whitespace, and optional syntax elements while preserving the code's functionality.

Why Minify Code?

Minification reduces file sizes, which leads to faster page load times and lower bandwidth usage. Smaller files mean quicker downloads for your users and improved web performance scores.

JavaScript

Powered by Terser with mangle, compress, and dead code elimination for maximum optimization.

CSS

Removes comments, collapses whitespace, shortens hex colors, and optimizes zero values.

HTML

Removes comments, collapses whitespace, strips optional closing tags, and removes unnecessary attribute quotes.

Your Code Stays Private

All minification happens in your browser:

100% Client-Side Processing: Your code never leaves your device. No uploads, no tracking, no data collection.
  • No uploads — your code never leaves your device
  • No tracking — we don't collect or store any code you paste
  • Complete privacy — all processing happens locally in your browser

How to Use Code Minifier

1

Select Language

Choose the language tab (JavaScript, HTML, or CSS) from the navigation chips at the top.

2

Paste Your Code

Paste or type your code in the input panel on the left. The tool auto-minifies as you type.

3

Adjust Options

Configure language-specific options in the toolbar (e.g., Mangle, Compress, Remove comments).

4

View Results

View the minified output on the right with syntax highlighting and compression statistics.

5

Check Stats

Review the compression stats bar for original size, minified size, and savings percentage.

6

Copy or Download

Click Copy in the output header to copy the result, or Download to save as a file.

Quick Actions

Sample Code

Load example code for the current language to see minification in action.

Upload File

Load a file from your device instead of pasting code manually.

Download Output

Save the minified output as a file to your local device.

Clear All

Reset both input and output panels to start fresh.

Keyboard Shortcuts

Pro Tip: Use keyboard shortcuts to speed up your workflow and minify code more efficiently.
  • Ctrl + Enter — minify immediately (bypasses debounce delay)
  • Tab — insert 4 spaces for indentation in the input area

Features

JavaScript Minification

Powered by Terser — an industry-standard JavaScript compressor that supports modern ES6+ syntax and provides advanced optimization capabilities.

Mangle

Shorten variable and function names to reduce size.

  • Renames local variables
  • Shortens function names
  • Preserves functionality

Compress

Apply optimizations like dead code elimination and constant folding.

  • Removes unused code
  • Optimizes expressions
  • Reduces file size

Drop Console

Remove all console.log() and console.* calls.

  • Eliminates debug statements
  • Reduces production file size

Drop Debugger

Remove debugger statements from production code.

  • Cleans debugging code
  • Production-ready output

CSS Minification

  • Remove CSS comments (/* ... */)
  • Collapse whitespace and remove unnecessary spaces around selectors and properties
  • Shorten hex colors (#ffffff#fff)
  • Optimize zero values (0px0)
  • Remove trailing semicolons before closing braces
  • Preserve calc() expressions with required spaces
Before

Original CSS

/* Main styles */
.button {
    background-color: #ffffff;
    padding: 0px 10px;
    margin: 0px;
}
After

Minified CSS

.button{background-color:#fff;padding:0 10px;margin:0}

HTML Minification

  • Remove HTML comments while preserving conditional comments
  • Collapse whitespace between and around tags
  • Remove optional closing tags (</li>, </p>, </td>, etc.)
  • Remove unnecessary attribute quotes for simple values
  • Strip default type attributes (type="text/javascript", type="text/css")
  • Preserve content in <pre>, <script>, <style>, and <textarea> tags
Safe Minification: Content inside pre, script, style, and textarea tags is preserved exactly as written to maintain functionality.

General Features

Auto-Minification

Output updates automatically as you type with debounced processing for smooth performance.

Compression Stats

See original size, minified size, and percentage saved in real-time.

Syntax Highlighting

Minified output is highlighted with Prism.js for better readability.

File Upload

Upload files or paste code directly for quick processing.

Download Output

Download minified output as a file with one click.

Copy to Clipboard

Copy minified code to clipboard instantly for immediate use.
100% Client-Side: Your code never leaves your browser. All processing happens locally for maximum privacy and security.

Frequently Asked Questions

Is my code sent to a server?

No. All minification happens locally in your browser. Your code is never uploaded or stored anywhere. This ensures complete privacy and security for your source code.

What JavaScript engine does this use?

JavaScript minification is powered by Terser, a widely-used production-grade compressor that supports modern ES6+ syntax. Terser is the industry standard used by major frameworks and build tools.

Will minification break my code?

Minification preserves functionality. For JavaScript, Terser handles variable renaming safely. For HTML, content inside <pre>, <script>, <style>, and <textarea> tags is left untouched. For CSS, calc() expressions are preserved correctly.

Safe Processing: The tool uses proven algorithms that maintain code functionality while optimizing file size.

What does "Mangle" mean?

Mangle shortens local variable and function names (e.g., myVariable becomes a). This significantly reduces file size without affecting how the code runs.

Before Mangle
function calculateTotal(price, quantity) {
    return price * quantity;
}
After Mangle
function calculateTotal(a,b){return a*b}

What are "optional closing tags" in HTML?

In HTML5, certain closing tags like </li>, </p>, </td> are optional. Removing them reduces file size without affecting how browsers render the page.

  • Browsers automatically infer where these tags should close
  • This is part of the HTML5 specification
  • Reduces file size by 10-30% in typical HTML documents

How much file size reduction can I expect?

Results vary by language and code style. Here are typical compression rates:

JavaScript (with mangle + compress) 40-70%
CSS 20-40%
HTML 10-30%
Note: Actual savings depend on your code style, comments, whitespace, and optimization settings.

Can I minify multiple files at once?

Currently the tool processes one file at a time. You can upload a new file or paste new code to minify the next one. This approach ensures optimal performance and allows you to review each file's compression results individually.

Paste code into the input panel and it auto-minifies after a short delay
Press Ctrl+Enter to minify immediately without waiting
Use the Copy button in the output header to copy minified code
Click Sample to load example code for the current language
For JavaScript, enable Drop console to remove all console.log() calls
Check the compression stats bar to see how much file size you saved
All minification runs in your browser - no code is sent to any server
Want to learn more? Read documentation →
1/8
Start typing to search...
Searching...
No results found
Try searching with different keywords