InTab

JavaScript Minifier

Minify JavaScript with Terser: compress, shorten names and see the size saved.

Formatters: Pretty-print, minify, validate and compare. It runs in your browser, so nothing you enter is uploaded.

What it does

The JavaScript Minifier makes scripts smaller so they download and parse faster. It uses Terser, the minifier behind most modern build tools, to remove whitespace and comments, simplify expressions and shorten local variable names. The result shows how many bytes you saved.

How to use it

  1. Paste your code into Input, or click Sample.
  2. Click Minify.
  3. Leave Shorten names on for the smallest output; turn it off if other code needs your function's local names.
  4. Tick Keep license comments to keep /*! … */ and @license comments.
  5. Copy or download the result.

Example

function total(items) {
  // add up the prices
  let sum = 0;
  for (const item of items) {
    sum += item.price * item.qty;
  }
  return sum;
}

Minified:

function total(t){let o=0;for(const n of t)o+=n.price*n.qty;return o}

The function name total is kept because other code may call it; only the names inside it are shortened.

Good to know

  • Minifying is safe for normal code. Code that reads its own variable names at run time, such as eval or Function.prototype.toString, may need Shorten names off.
  • Your server should also send scripts compressed with gzip or Brotli. Minifying and compressing together give the smallest download.
  • If the code has a syntax error, the minifier stops and shows the line and column.

FAQ

Can I turn minified code back into readable code? Use the JavaScript Formatter. Layout comes back; shortened names and removed comments do not.

Does it support modern JavaScript? Yes: modules, classes, async functions, optional chaining and other recent syntax.

More Formatters tools

  • JSON Formatter: Beautify, minify, validate and sort JSON. Handles escaped/stringified JSON.
  • XML Formatter: Beautify, minify and validate XML documents.
  • SQL Formatter: Format SQL for MySQL, PostgreSQL, T-SQL, SQLite and more.
  • Diff Finder: Compare two texts or JSON documents line by line or word by word.
  • Text Diff Checker: Paste two versions of a text and see exactly which words changed.
  • JSON Validator: Check JSON is valid and see the exact line, column and a fix hint when it is not.
  • JavaScript Formatter: Beautify minified or messy JavaScript with your choice of indentation.
  • HTML Formatter: Indent and tidy HTML, or minify it for production.
  • CSS Formatter: Beautify CSS with one rule per block and consistent indentation.
  • CSS Minifier: Minify CSS with CSSO: remove whitespace, merge rules and shorten values.
  • YAML Formatter: Validate and re-indent YAML, keeping comments, with optional key sorting.