Skip to main content
tolio

JavaScript Minifier

Minify JavaScript code instantly — paste JS or upload a .js/.mjs file. Three minification levels: Basic (strip comments), Medium (collapse whitespace), Advanced (full minification with boolean optimization). No upload required, 100% free, fully private. Best free online JavaScript minifier.

Minification Level
50%Medium
AdvancedMediumBasic
Collapse whitespace & spacing (recommended)

50 MB

Max file size

.js / .mjs

File format

100% local

Privacy

~5 seconds

Speed

3 levels

Minification

Free forever

Price

Related Tools

What is JavaScript Minifier?

JavaScript files often contain comments, extensive whitespace, verbose formatting, and unreachable code that bloat file sizes and slow down page loads. The JavaScript Minifier tool strips everything your browser does not need to execute scripts, giving you lean, production-ready JS in seconds.

Whether you are optimizing a React application, reducing load times on an e-commerce site, or cleaning up scripts before deployment, this tool gives you complete control over how aggressively your JavaScript is compressed. Three distinct minification levels let you choose between preserving readability for development or achieving maximum compression for production.

The tool works with two input modes: paste your JavaScript code directly or upload a .js / .mjs file. The gradient slider lets you dial in the perfect level of compression, and the 5-second processing spinner ensures you always see visual feedback. All processing happens locally in your browser — your code never leaves your device, making it safe for proprietary or client JavaScript.

How to Use JavaScript Minifier

  1. Choose your input by clicking "Paste Code" or "Upload File" at the top of the tool.
  2. Paste your JavaScript code into the text area or drag-and-drop a .js / .mjs file onto the upload zone (max 50 MB).
  3. Adjust the minification level using the gradient slider. Drag left for Advanced compression or right for Basic minification. The current level (Basic, Medium, or Advanced) is displayed above the slider.
  4. Click "Minify JavaScript" to start the conversion. A loading spinner will appear with a progress percentage.
  5. After approximately 5 seconds, the result is displayed. Review the before-and-after stats including file size, line count, and percentage saved.
  6. Use the download button to save the minified .js file, or copy the compressed code to your clipboard. Click "Minify Another" to start over with a fresh file or code snippet.

Pro tip: For maximum compression, set the slider to Advanced and minify your JavaScript before deploying to production. The Advanced level also converts boolean literals (true becomes !0, false becomes !1) and removes "use strict" directives for optimal size reduction. Keep a copy of the original for development work.

Example

Before:

// Calculate total with tax
function calculateTotal(price, taxRate) {
  const tax = price * taxRate;
  const total = price + tax;
  return total;
}

// Format price output
function formatPrice(amount) {
  return "$" + amount.toFixed(2);
}

console.log(calculateTotal(100, 0.1));

After (Medium):

function calculateTotal(price,taxRate){const tax=price*taxRate;const total=price+tax;return total;}
function formatPrice(amount){return "$"+amount.toFixed(2);}
console.log(calculateTotal(100,0.1));

After (Advanced):

function calculateTotal(price,taxRate){const tax=price*taxRate;const total=price+tax;return total}
function formatPrice(amount){return "$"+amount.toFixed(2)}
console.log(calculateTotal(100,0.1))

Advanced also removes trailing semicolons before closing braces, strips "use strict" directives, converts true to !0 and false to !1, and replaces undefined with void 0 for maximum compression.

Frequently Asked Questions

Does the JavaScript Minifier remove comments?

Yes. At all three levels (Basic, Medium, Advanced), the tool strips JavaScript comments (// and /* */). This is essential for reducing file size and is completely safe since comments have no effect on execution.

What is the difference between Basic, Medium, and Advanced?

Basic removes comments and trailing whitespace only. Medium does everything Basic does plus collapses whitespace, removes unnecessary newlines, and tightens spacing around operators and syntax tokens like {, }, (, ), ;, and commas. Advanced does everything Medium does plus converts true to !0, false to !1, undefined to void 0, removes trailing semicolons before closing braces, and strips "use strict" directives.

Can I use this tool on mobile devices?

Yes, the tool is fully responsive and works on any modern mobile browser. You can paste JavaScript code directly or upload .js / .mjs files from your phone or tablet. The gradient slider works with touch input.

Is the JavaScript Minifier free to use?

Yes, completely free with no hidden costs, subscriptions, or premium tiers. All three minification levels are available without any payment or registration.

Is my JavaScript data stored or uploaded?

No. Everything runs locally in your browser using client-side JavaScript. Your code never leaves your device, ensuring complete privacy for proprietary or client scripts.

What is the maximum file size?

The maximum file upload size is 50 MB. If your file exceeds this limit, you will see a clear error message explaining the constraint. For paste mode, there is no hard limit but very large amounts of code may affect performance.

How much can I reduce my JavaScript file size?

Typical savings range from 20-40% for well-structured JavaScript. Files with excessive comments, large blocks of whitespace, or verbose formatting can see reductions of 50% or more. The tool shows an honest before-and-after comparison.

Does the tool handle JavaScript minification safely?

Yes. The minification engine is designed to be safe — it only removes comments, collapses whitespace around syntax tokens, and performs basic literal optimizations. It does not rename variables, alter functionality, or remove any code that affects execution logic. Your scripts will work identically after minification.

Can I use this tool for production JavaScript?

Absolutely. The Advanced level produces output suitable for production deployment. We recommend keeping a copy of your original JS for development editing, then running it through this tool before deploying to production servers.

What does the gradient slider represent?

The slider controls the minification level, not a quality threshold. Red/yellow/green represents the aggressiveness: red area (left) = Advanced (full minification), yellow area (middle) = Medium (balanced), green area (right) = Basic (minimal changes). The current level and a description are displayed below the slider.

Does the tool preserve the original file name?

Yes. When you upload a .js or .mjs file, the minified output is saved with the same base name plus .min.js appended (e.g. "script.min.js"). In paste mode, the file is saved as "minified.min.js".

Can I copy the minified JavaScript directly?

Yes. After minification, the output is displayed in a read-only textarea. A "Copy to Clipboard" button lets you copy the content with one click. You can also manually select and copy from the textarea.

Does the tool work with modern JavaScript (ES6+, JSX, TypeScript)?

The tool works best with standard JavaScript. JSX, TypeScript, and other syntax extensions may not be fully minified because the tool treats these as plain JS syntax. For best results, compile your TypeScript or JSX files to plain JavaScript before minifying.

What does the 5-second spinner mean?

The 5-second spinner provides consistent visual feedback during processing. Even though the actual JavaScript minification completes almost instantly, the spinner ensures the user sees a clear transition from input to output. The progress indicator shows the percentage of the spinner duration completed.

Key Takeaways

  • Minify JavaScript by pasting code or uploading a .js /.mjs file — three compression levels from Basic to Advanced
  • Basic strips comments and trailing whitespace — perfect for quick cleanup
  • Medium collapses all whitespace, removes newlines, and tightens spacing around operators and syntax tokens
  • Advanced does everything plus boolean literal optimization (!0, !1), void 0 replacement, and "use strict" removal
  • Reduces JavaScript file size by 20-50% on average, displayed in clear before-and-after stats
  • All processing is 100% local — no JavaScript code is uploaded to any server
  • Gradient slider with Advanced/Medium/Basic labels provides intuitive control over minification aggressiveness
  • Download the minified .js file or copy the output directly to your clipboard
  • Real-time file size comparison (bytes, % savings, line count) after processing
  • 5-second processing spinner with progress percentage for clear visual feedback
  • Works on all devices including mobile, tablet, and desktop with responsive layout
  • 100% free with no registration, watermarks, or usage limits
Was this helpful?