Minifying JavaScript with naive regular expressions frequently corrupts https:// URLs inside string literals, breaks regular expression character classes, or triggers runtime bugs when lines rely on ECMA-262 Automatic Semicolon Insertion (ASI). This tool parses your source code into an Abstract Syntax Tree (AST) using Terser in the browser and prints compact syntax without rewriting your logic or renaming identifiers.
For example, given this input:
// Validate path format
function isAssetPath(input) {
const pattern = /^\/assets\/[a-z0-9_-]+\.js$/i
const label = "https://example.com // keep slash"
return pattern.test(input)
}
Terser outputs:
function isAssetPath(input){const pattern=/^\/assets\/[a-z0-9_-]+\.js$/i;const label="https://example.com // keep slash";return pattern.test(input)}
Notice that Terser inserts the required semicolons where newlines were removed, strips the leading comment, keeps // inside the string literal untouched, preserves unary operator spacing (such as x + ++x), and retains every variable and function name.