terser /terser

🗜 JavaScript parser, mangler and compressor toolkit for ES6+

★ 9,357⑂ 494👁 50⑃ 597● 1,181▤ 0
JavaScriptNOASSERTIONCreated 2015-01-11terser.org
+0
Daily
9,357
stars
494
forks
50
watchers
597
prs
1,181
issues
0
releases

README

[![NPM Version][npm-image]][npm-url]
  [![NPM Downloads][downloads-image]][downloads-url]
  [![CI pipeline][ci-image]][ci-url]
  [![Opencollective financial contributors][opencollective-contributors]][opencollective-url]

A JavaScript mangler/compressor toolkit for ES6+.

note: You can support this project on patreon: [link] The Terser Patreon is shutting down in favor of opencollective. Check out PATRONS.md for our first-tier patrons.

Terser recommends you use RollupJS to bundle your modules, as that produces smaller code overall.

Beautification has been undocumented and is being removed from terser, we recommend you use prettier.

Find the changelog in CHANGELOG.md



[npm-image]: https://img.shields.io/npm/v/terser.svg
[npm-url]: https://npmjs.org/package/terser
[downloads-image]: https://img.shields.io/npm/dm/terser.svg
[downloads-url]: https://npmjs.org/package/terser
[ci-image]: https://github.com/terser/terser/actions/workflows/ci.yml/badge.svg
[ci-url]: https://github.com/terser/terser/actions/workflows/ci.yml
[opencollective-contributors]: https://opencollective.com/terser/tiers/badge.svg
[opencollective-url]: https://opencollective.com/terser

Why choose terser?
------------------

uglify-es is no longer maintained and uglify-js does not support ES6+.

terser is a fork of uglify-es that mostly retains API and CLI compatibility
with uglify-es and uglify-js@3.

Install
-------

First make sure you have installed the latest version of node.js
(You may need to restart your computer after this step).

From NPM for use as a command line app:

    npm install terser -g

From NPM for programmatic use:

    npm install terser

 Command line usage




terser [input files] [options]


Terser can take multiple input files.  It's recommended that you pass the
input files first, then pass the options.  Terser will parse input files
in sequence and apply any compression options.  The files are parsed in the
same global scope, that is, a reference from a file to some
variable/function declared in another file will be matched properly.

Command line arguments that take options (like --parse, --compress, --mangle and
--format) can take in a comma-separated list of default option overrides. For
instance:

    terser input.js --compress ecma=2015,computed_props=false

If no input file is specified, Terser will read from STDIN.

If you wish to pass your options before the input files, separate the two with
a double dash to prevent input files being used as option arguments:

    terser --compress --mangle -- input.js

 Command line options


    -h, --help                  Print usage information.
                                --help options for details on available options.
    -V, --version               Print version number.
    -p, --parse        Specify parser options:
                                acorn  Use Acorn for parsing.
                                bare_returns  Allow return outside of functions.
                                       

Top issues

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON