JavaScript Minifier & Beautifier

Developer Tools

Minify JavaScript for production, or beautify minified code so you can read it.

Options
JavaScript
Minified

Processed in your browser. A copy of each run is saved to your past runs so you can reopen it. Privacy

About

What the JavaScript Minifier does

The JavaScript Minifier shrinks code with Terser, the minifier used by most JavaScript build tools: it removes whitespace and comments, shortens local variable names, drops dead code and can strip console calls. The Beautify tab does the reverse, re-indenting minified code so it can be read. The status line shows the size before and after and an estimate of the gzipped size. Syntax errors show their line and column.

Steps

How to use it

  1. 1Choose Minify or Beautify.
  2. 2Paste the code or upload a .js file, and set the options.
  3. 3Press the button, check the sizes, and copy or download the result.

Example

A real run

Input

// Format a price for display in US dollars.
function formatPrice(amount, currency) {
  if (typeof amount !== "number" || Number.isNaN(amount)) {
    throw new TypeError("amount must be a number");
  }
  const formatter = new Intl.NumberFormat("en-US", {
    style: "currency",
    currency: currency || "USD",
  });
  return formatter.format(amount);
}

export function cartTotal(items) {
  let total = 0;
  for (const item of items) {
    total += item.price * item.quantity;
  }
  return formatPrice(total);
}

Output

export function cartTotal(r){let t=0;for(const e of r)t+=e.price*e.quantity;return function(r){if("number"!=typeof r||Number.isNaN(r))throw new TypeError("amount must be a number");return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(r)}(t)}

512 B → 267 B · 47.9% smaller

Comments and whitespace go, local names become single letters and Terser inlines the helper into its only caller; the exported name cartTotal is kept so other code can still import it.

Options

Every setting, and when to use it

Shorten variable names
Renames local variables and parameters to one or two letters, the biggest saving after whitespace. Exported names and properties are never renamed, so other code keeps working.
Remove console calls
Deletes console.log and friends from production builds. Leave it off if the code relies on console output, or while debugging.
Output for
ES2020 lets Terser use modern, shorter syntax; ES5 keeps output compatible with very old browsers. This sets what the output may use; it does not convert modern syntax down.
Beautify: indent and braces
Re-indents code with 2 or 4 spaces or tabs and puts braces on the same line or the next. Names shortened by a minifier stay short; beautifying cannot recover them.

Good to know

Common problems and limits

Code up to 5 MB, minified in a background worker that is stopped after 10 seconds. ES modules (import/export) are detected automatically.

No source maps are produced. Minify one file at a time; bundling several files is a build tool's job.

For stylesheets use the CSS Minifier; for JSON use the JSON Minifier; for markup use the HTML Formatter.

Audience

Who uses it

  • Front-end developersShrink a script for a page, a CMS embed or a bookmarklet that does not go through a build step.
  • Developers debugging productionBeautify a minified bundle or third-party script to read what it does.
  • Students and learnersSee how a minifier rewrites code and how much each technique saves.

FAQ

Frequently asked

What is the difference between minify, uglify and obfuscate?

Minifying removes whitespace and comments and shortens names to make code smaller. Uglify is the name of an older minifier, now used loosely for the same thing. Obfuscation deliberately makes code hard to understand, with tricks that often make it larger; minified code is still readable after beautifying, just with short names.

Can minifying break my code?

Rarely, with Terser's default settings, because it only applies transformations that keep behavior the same. Problems come from code that depends on function or variable names at runtime, or from relying on side effects in code Terser considers dead. Test the minified file before shipping it.

How do I un-minify JavaScript?

Use the Beautify tab: it restores indentation and line breaks so the structure is readable. Original names and comments are gone after minifying, so short names such as a and b remain; a source map, if the site published one, is the only way to get them back.

Do I need this if I use Vite or webpack?

No. Vite, webpack, esbuild and Next.js minify production builds automatically, often with Terser or esbuild. This page is for code outside a build: snippets, embeds, bookmarklets, or quickly checking what minification does.

How much smaller does minified JavaScript get?

Typically 30 to 60 percent before compression, depending on comments, whitespace and name lengths. Servers also gzip or Brotli-compress files, which shrinks them further; the status line estimates the gzipped size.

Is my code sent anywhere?

No. Minifying and beautifying happen in your browser, minifying in a background worker. A copy of each run is saved to your past runs so you can reopen it.

Automation: an MCP tool minify_js(code, options), beautify_js(code) and an n8n node are planned for this tool.

GuideA web developer's toolbox: timestamps, cron, permissions and headers →Unix timestamps in seconds or milliseconds, cron fields and time zones, chmod numbers, HAR files and user agents: the details web developers look up.
Built and maintained by Radhika SinghLast updated Questions: hello@operativez.ai