What is Terser?

Updated

Terser is an industry-standard minifier for JavaScript. It shrinks variable names, removes whitespace and comments, and drops unused code. You can use it through the command line or the Node.js API. If you need to reduce the size of JavaScript you ship to the browser or run in Node.js, Terser is the tool this site documents.

What Terser actually does

Terser is described on terser.org as a "JavaScript mangler and compressor toolkit." Those two words map to two distinct jobs:

  • Mangling — shortening variable and function names (for example, turning a descriptive identifier into a single character) so the code takes fewer bytes without changing behavior.
  • Compressing — removing whitespace and comments, and dropping code that is never used.

The result is smaller JavaScript that behaves the same as the original, which is why it is called a minifier rather than a formatter or a bundler.

How you use it

Terser exposes two entry points, both listed on the site:

Interface What it is for
Command line Running Terser as a CLI tool over files or input
Node.js API Calling Terser programmatically from JavaScript build code

The site links to dedicated CLI Usage and API Reference documentation for each. If you are wiring minification into a build pipeline, the Node.js API is the programmatic route; if you just want to minify a file or a stream, the CLI is the direct one.

Why it matters

Terser is not a niche utility — the site states it is an "industry-standard minifier for JavaScript code." That status comes from being the minifier that many build tools and projects rely on to cut payload size. Smaller JavaScript means less to download, parse, and execute, which is the practical reason minification sits in most production build steps.

Where to go next

  • Docs — API Docs, CLI Docs, and an Options reference for configuring behavior.
  • REPL — an interactive environment to try Terser on code directly.
  • GitHub — source, issues, and contribution entry points.
  • Community — a Stack Overflow link and a blog for questions and write-ups.

Terser is also sustained by contributors: the site lists code contributors plus individual and organization financial contributors, with a Contribute link for each.