Skip to content

JavaScript Minifier

The JavaScript Minifier removes comments and whitespace from your JS to reduce file size. It's a lightweight minifier: it reads strings, template literals and regular expressions so their contents never change, and keeps a line break wherever JavaScript's automatic semicolon insertion depends on it. Everything runs in your browser, so proprietary code never leaves your machine.

A lightweight minifier

It removes comments and whitespace only, keeping strings, template literals and regular expressions exactly as written, and keeps a line break wherever automatic semicolon insertion depends on it. It doesn't rename variables or drop dead code. For production builds use Terser or esbuild, which also shorten names and remove unused code.

JavaScript

Runs in your browser as you type. Nothing is uploaded.

Original
679 B
Output
485 B
Saved
28.6%
194 B smaller
Minified
/*! cart.js v1.2 | MIT License */
function formatPrice(cents,currency="USD"){const amount=cents/100;return new Intl.NumberFormat("en-US",{style:"currency",currency}).format(amount);}
export function cartLabel(items){const total=items.reduce((sum,item)=>sum+item.price*item.qty,0);const count=items.length;const label=`${count} item${count===1?"":"s"}: ${formatPrice(total)}`;return label.replace(/\s+/g," ").trim();}
let retries=0
retries++
console.log(cartLabel([{price:1999,qty:2}]))

How to use

  1. Paste your JavaScript into the input box.
  2. Choose whether to keep license comments (/*! ... */, @license, @preserve).
  3. The minified output and the size saved update as you type. Problems like an unclosed string are reported with a line and column.
  4. Copy the code or download it as a .min.js file.

Why use this tool?

Sometimes you need to shrink one inline script or snippet without setting up a build pipeline. This tool does that safely in seconds, with no npm install. For full production bundles, a parser-based minifier such as Terser or esbuild goes further by shortening variable names and removing unused code.

Frequently asked questions

What is the JavaScript Minifier?

A browser-based tool that compresses JavaScript by stripping comments and unnecessary whitespace without changing how the code runs. It doesn't rename variables or remove code.

Will minifying my JavaScript break my code?

Removing whitespace and comments is safe for valid JavaScript. This minifier keeps strings, template literals and regular expressions byte for byte and keeps a line break wherever removing it could change how semicolons are inserted, for example after return. It doesn't fully parse your code, so very unusual syntax can trip it: test minified output before deploying, and use Terser or esbuild for production builds.

Why is the output bigger than a Terser or esbuild build?

Terser and esbuild rename local variables to short names and drop unreachable code, which this tool deliberately doesn't do. Use it for quick minification of snippets and inline scripts, and a build tool for whole bundles.

Is it free?

Yes, the JavaScript Minifier is free with no signup required. It runs entirely in your browser, so nothing you paste is uploaded. Built by the Canvas Builder team.

Stop tweaking snippets. Build the whole site

This tool fixes one piece. Canvas Builder builds the entire page from a single prompt: sections, copy, styling, and responsive layout. You own the code.