Skip to content
QuickTool logoQuickTool

JS Minifier

Minify JavaScript (naïve) for quick use

Start

function add(a, b) { return a + b; }
Naïve minification; avoid for production bundles.

Description

The JS Minifier removes comments and collapses whitespace in a simple, fast way. It’s intended for small examples and quick sharing—not production bundling.

You can toggle removal of line and block comments and control whitespace collapsing.

Key features

  • Strip // and /* */ comments
  • Collapse multiple spaces and newlines
  • Copy minified code with one click

Common use cases

  • Sharing compact code samples
  • Testing payload differences
  • Embedding snippets in HTML

Privacy & security: minification runs locally in your browser.

How to Use

  1. Paste JavaScript in the left panel.
  2. Toggle removal of line and block comments.
  3. Enable whitespace collapsing if desired.
  4. Review the output and click “Copy Output”.
  5. Use “Sample” to try a demo snippet.

Tips

  • Do not use for production; use a bundler/minifier.
  • Beware of regex literals that may resemble comments.

Troubleshooting

  • Code breaks → Disable comment stripping and verify regexes/strings.
  • No change → Input already compact; add comments to test.

Example

Example: Remove comments

Input:

// comment
function add(a, b) {
  /* sum two numbers */
  return a + b;
}

Output:

function add(a,b){return a+b}

FAQ

Is it local?

Yes. Runs in your browser only.

Is it safe for production?

No. It’s a naïve pass; use a real minifier for production.

Why did a regex break?

Comment stripping can misinterpret some patterns; disable it if issues arise.