JavaScript Minifier

Minify JavaScript code instantly with the JavaScript Minifier Tool. Remove comments, whitespace, and line breaks for compact output. Includes live preview, file import/export, copy, and character count. Validate your input with an optional toggle.

Paste your input above or import a file below.
No file chosen
Supported file types: .txt, .js
Total characters: 0
Options
Remove comments
Collapse whitespace
Remove line breaks
Validate input

How to Use:

  1. Paste your JavaScript into the Input JavaScript box.
  2. Or use the Choose File button to import a .js or .txt file.
  3. Adjust options such as:
    • Remove comments
    • Collapse whitespace
    • Remove line breaks
    • Validate input (optional syntax check)
  4. The Minified Output updates instantly as you type or toggle options.
  5. Use Copy Output or Export to File to save the result.
  6. Click Clear All to reset everything.

What the JavaScript Minifier Tool can do:

  • Strips single-line (//) and multi-line (/* */) comments.
  • Collapses excess whitespace to single spaces.
  • Removes line breaks to compress output into a single line.
  • Optionally validates syntax using the Function() constructor.
  • Displays live character count and flashes output on changes.
  • Includes file import, export, copy, and full reset support.

Example:

Input:

// greeting
function greet(name) {
console.log(\"Hello, \" + name);
}
/* comment block */
greet(\"Alice\");

Options Enabled:

  • Remove comments
  • Collapse whitespace
  • Remove line breaks

Output:

function greet(name) { console.log(\"Hello, \" + name); } greet(\"Alice\");

Common Use Cases:

Perfect for compressing scripts before publishing or embedding, the JavaScript Minifier Tool helps reduce file size, remove development notes, and streamline output. Useful for inline scripts, CMS fields, or when preparing JavaScript for production.

Useful Tools & Suggestions:

Before minifying your script, JavaScript Prettifier is great for catching bugs or cleaning up messy code it’s easier to fix issues before everything’s crammed onto one line. And if your script works with structured data, JSON Minifier can help keep your config files lean too.