Safe JavaScript Minifier

Compact JavaScript conservatively without deleting comments, line boundaries or content inside strings.

Tool

Result will appear here...

Example

function test() {
    console.log("Hello");
}

Output:

function test() {
console.log("Hello");
}

How to use

  1. Paste your JavaScript
  2. Click Minify
  3. Copy the result

What is this tool?

This browser tool removes blank lines and trailing whitespace while preserving comments and JavaScript line boundaries. That is deliberately more conservative than a parser-backed production minifier, because deleting comments or joining lines with regular expressions can corrupt URLs, regular-expression literals, template strings and automatic semicolon insertion.

Use a parser-backed build tool such as Terser for production bundles. Use this tool for quick, low-risk cleanup when preserving behavior matters more than maximum compression.

Related tools

🎨 CSS Minifier 🧹 JSON Minifier ✨ Code Beautifier