Terser
terser.org
What it is
Terser is a free, open-source JavaScript minifier that reduces code by shortening variable names, removing whitespace and comments, and dropping unused code. It can be used through a command-line interface or Node.js API; browser loading is supported and exposes a global `Terser` variable with a `.minify` property. The API’s `minify()` enables compression and mangling by default, and both settings can be changed or turned off. The API can return a source map, while the CLI can generate source maps for compressed JavaScript. The CLI accepts multiple input files and parses them in sequence in one global scope, or reads from standard input when no input file is specified. Compatibility options include an ECMAScript target; `ecma` defaults to 5 for compression and output formatting. Property-name mangling can break code, so the documentation says to use it only when its behavior is understood. Built-in DOM property mangling is disabled by default and is not recommended for enabling. Terser also supports Acorn-produced SpiderMonkey AST input and a Yarn resolution alias for nested `uglify-es` dependencies.
Spec sheet
- Purpose
- Terser is an industry-standard JavaScript minifier that shrinks variable names, removes whitespace and comments, and drops unused code.Read 4 Oct 2026 · terser.org
- Integrations
- The project documentation describes using Terser with Acorn-produced SpiderMonkey AST input and replacing nested `uglify-es` dependencies with a Yarn resolution alias.Read 4 Oct 2026 · terser.org
- Support
- The site links to Stack Overflow as a community resource, and its issue-reporting guide asks users to provide a minimal reproducible example.Read 4 Oct 2026 · terser.org
- Browser use
- The API reference says browser loading is supported and exposes a global `Terser` variable with a `.minify` property.Read 4 Oct 2026 · terser.org
- Compatibility options
- Terser provides options for ECMAScript targets, including an `ecma` setting that defaults to 5 for compression and output formatting.Read 4 Oct 2026 · terser.org
- Compression and mangling
- The API's `minify()` enables compression and mangling by default, and both can be configured or disabled.Read 4 Oct 2026 · terser.org
- Funding
- The site invites individual and organizational financial contributions to support the project.Read 4 Oct 2026 · terser.org
- Input stream
- If no input file is specified, the CLI reads from standard input.Read 4 Oct 2026 · terser.org
- Multiple input files
- The CLI accepts multiple input files and parses them in sequence in the same global scope.Read 4 Oct 2026 · terser.org
- Property mangling risk
- The CLI documentation warns that property-name mangling can break code and advises using it only when its behavior is understood.Read 4 Oct 2026 · terser.org
- Property mangling safeguards
- The options documentation says built-in DOM property mangling is disabled by default and is not recommended to enable.Read 4 Oct 2026 · terser.org
- Source maps
- The API can return a source map, and the CLI can generate source maps for compressed JavaScript.Read 4 Oct 2026 · terser.org
- Ways to use
- The site says Terser can be used through its command-line interface or Node.js API.Read 4 Oct 2026 · terser.org
Plans and prices
Strong points and limits
Strong points
- Free, open-source toolkit
- CLI and Node.js API available
- Can generate source maps
- Accepts multiple CLI input files
Limits
- Property-name mangling can break code
- Built-in DOM property mangling is not recommended
Who it suits
Terser suits developers who need to minify JavaScript through a CLI, Node.js API or browser loading. Users considering property-name mangling should understand its possible effects on their code.
Verdict
Terser provides configurable compression, mangling and source-map options across command-line and API workflows. Treat property-name mangling carefully, particularly for DOM properties.
Where Specifiction places it
- JavaScript Build Tools#13 of 277.7