Skip to content
SPECIFICTION
Get listed

Google Closure Compiler vs Terser

Google Closure Compiler

developers.google.com

Terser

terser.org

Side by side

FigureGoogle Closure CompilerTerser
Price fromFreeFree
Free planYesYes
Free trial——
Open source——
Web—Yes
WindowsYesYes
macOSYesYes
LinuxYesYes
API—Yes
Self-hostedYes—
Plans published11
Spec score · JavaScript Build Tools8.1 (#6)7.7 (#13)
IntegrationsThe repository documents a NodeJS API and use through Maven, NPM, Bazel, and command-line Java.The project documentation describes using Terser with Acorn-produced SpiderMonkey AST input and replacing nested `uglify-es` dependencies with a Yarn resolution alias.
PurposeClosure Compiler optimizes JavaScript by analyzing it, removing dead code, rewriting and minimizing what remains, and checking syntax, references, and types.Terser is an industry-standard JavaScript minifier that shrinks variable names, removes whitespace and comments, and drops unused code.
Ways to useThe project page describes an open source command-line Java application, a library used via Bazel, and an NPM package.The site says Terser can be used through its command-line interface or Node.js API.

Plans

Google Closure Compiler

  • Closure CompilerFree

Google Closure Compiler pricing →

Terser

  • TerserFree

Terser pricing →

In their own words

Google Closure Compiler

Google Closure Compiler optimizes JavaScript by analyzing code, removing dead code, and rewriting and minimizing what remains. It can also check syntax, references, and types, and warn about illegal JavaScript, risky operations, and common pitfalls. Google says smaller output files can help applications load faster and reduce bandwidth needs. Compilation options include WHITESPACE_ONLY, SIMPLE, and ADVANCED; the repository README also lists BUNDLE. ADVANCED applies aggressive transformations and symbol renaming to improve compression, so preserving program behavior requires care. The project is available as a command-line Java application, a library used through Bazel, and an NPM package. Released JARs are distributed through Maven. The repository documents Maven, NPM, Bazel, command-line Java, and a NodeJS API. Building the compiler requires Java 21 or later, NodeJS, Git, and Bazelisk. Its input restrictions include use of goog.module() and goog.require(), and ES6 import/export support is not actively maintained. The NPM packages are built and distributed by an open source contributor, not Google. The compiler is free.

Visit developers.google.com

Terser

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.

Visit terser.org