Frontend ToolsA little help for every day

Search by name or task, such as JSON or percentage.

Frontend Tools

JS Minifier: Compress JavaScript Online

Minify JavaScript by removing comments and whitespace without breaking strings, regexes or template literals. Keeps licence comments and shows bytes saved.

View all tools
ResultUpdates as you type

219 bytes → 150 bytes, 31.5% smaller. Only comments and whitespace are removed (no renaming); line breaks are kept where automatic semicolon insertion needs them.

function greet(name){const url="https://example.com/"+name;let count=1
count=count- -1
return`Hello, ${name}! Visit ${url}`}
console.log(greet("Ada"))

How to use JS Minifier: Compress JavaScript Online

Paste JavaScript into the box and the minified code, with its byte saving, appears as you type. Untick the licence option if you also want /*! */ comments removed, then copy the output.

  1. Paste your JavaScriptPaste a script, function or snippet. Template literals, arrow functions and optional chaining are fine.
  2. Decide on licence commentsKeep /*! … */ licence comments is on by default; untick it to remove every comment.
  3. Copy the resultCheck the byte count and copy the code. Run your tests against the minified file before deploying it.

Before and after: what changes

The sample function is 219 bytes and minifies to 150 bytes, 31.5% smaller. Comments go, including one placed after a string that itself contains //, because the code is split into tokens first. count = count - -1 becomes count=count- -1: the space stays because a--1 would mean something different. The sample also leaves out semicolons, so line breaks are kept between those statements, where automatic semicolon insertion relies on them. That is why the output is not always a single line.

How this differs from Terser or esbuild

Only comments and whitespace are removed. Variables are not renamed, dead code is not dropped and statements are not merged, so the output stays readable and the saving is smaller than a build tool such as Terser or esbuild would give. That makes it a good fit for inline scripts, small snippets and quick checks, not for protecting source code. JSX and TypeScript are not plain JavaScript, so compile them first; the tokeniser does not understand JSX tags or type annotations.

Accuracy and data handling

After adding generated code to a project, test it in the target browsers and responsive sizes. The calculation runs in your current browser; the tool code does not send the input to a processing API.

Often Used Together

Next step

FAQ

Why is my minified code still on several lines?

When statements aren't ended with semicolons, some line breaks are what separates them. Removing those would change what the code does, so a line break is kept only where automatic semicolon insertion depends on it.

Does it obfuscate or rename variables?

No. Names, structure and logic are untouched; only comments and whitespace go. Anyone can still read the result, so it isn't a way to hide source code.

My code fails after minifying. What should I check?

First confirm the original runs. Strings, regular expressions and template literals are kept exactly, so the usual cause is JSX or TypeScript syntax, which must be compiled to plain JavaScript first.

More Frontend Tools

Related tools