Show output

Powered by Terser!

Compression settings


Arrows (arrows): Class and object literal methods are converted will also be converted to arrow expressions if the resultant code is shorter: `m(){return x}` becomes `m:()=>x`. To do this to regular ES5 functions which don't use `this` or `arguments`, see `unsafe_arrows`.


Arguments (arguments): Replace `arguments[index]` with function parameter name whenever possible.


Booleans (booleans): Various optimizations for boolean context, for example `!!a ? b : c → a ? b : c`.

Booleans as integers

Booleans as integers (booleans_as_integers): Turn booleans into 0 and 1, also makes comparisons with booleans use `==` and `!=` instead of `===` and `!==`.

Collapse vars

Collapse vars (collapse_vars): Collapse single-use non-constant variables, side effects permitting.


Comparisons (comparisons): Apply certain optimizations to binary nodes, e.g. `!(a <= b) → a > b,` attempts to negate binary nodes, e.g. `a = !b && !c && !d && !e → a=!(b||c||d||e)` etc.

Computed props

Computed props (computed_props): Transforms constant computed properties into regular ones: `{["computed"]: 1}` is converted to `{computed: 1}`.


Conditionals (conditionals): Apply optimizations for `if`-s and conditional expressions.

Dead code

Dead code (dead_code): Remove unreachable code.


Directives (directives): Remove redundant or non-standard directives.

Drop console

Drop console (drop_console): Pass `true` to discard calls to `console.*` functions. If you wish to drop a specific function call such as `console.info` and/or retain side effects from function arguments after dropping the function call then use `pure_funcs` instead.

Drop debugger

Drop debugger (drop_debugger): Remove `debugger;` statements.


ECMA (ecma): Pass `2015` or greater to enable `compress` options that will transform ES5 code into smaller ES6+ equivalent forms.
  • 5

  • 2015

  • 2016

  • 2017

  • 2018

  • 2019

  • 2020


Evaluate (evaluate): Attempt to evaluate constant expressions.


Expression (expression): Pass `true` to preserve completion values from terminal statements without `return`, e.g. in bookmarklets.

Hoist functions

Hoist functions (hoist_funs): Hoist function declarations.

Hoist properties

Hoist properties (hoist_props): Hoist properties from constant object and array literals into regular variables subject to a set of constraints. For example: `var o={p:1, q:2}; f(o.p, o.q);` is converted to `f(1, 2);`. Note: `hoist_props` works best with `mangle` enabled, the `compress` option `passes` set to `2` or higher, and the `compress` option `toplevel` enabled.

Hoist variables

Hoist variables (hoist_vars): Hoist `var` declarations (this is `false` by default because it seems to increase the size of the output in general).

If return

If return (if_return): Optimizations for if/return and if/continue.


Inline (inline): Inline calls to function with simple/return statement: - `Disabled` -- disabled inlining - `SimpleFunctions` -- inline simple functions - `WithArguments` -- inline functions with arguments - `WithArgumentsAndVariables` -- inline functions with arguments and variables
  • Disabled

  • SimpleFunctions

  • WithArguments

  • WithArgumentsAndVariables

Join variables

Join variables (join_vars): Join consecutive `var` statements

Keep class names

Keep class names (keep_classnames): Pass `true` to prevent the compressor from discarding class names. Pass a regular expression to only keep class names matching that regex. See also: the `keep_classnames` mangle option.

Keep function arguments

Keep function arguments (keep_fargs): Prevents the compressor from discarding unused function arguments. You need this for code which relies on `Function.length`.

Keep function names

Keep function names (keep_fnames): Pass `true` to prevent the compressor from discarding function names. Pass a regular expression to only keep function names matching that regex. Useful for code relying on `Function.prototype.name`. See also: the `keep_fnames` mangle option.

Keep infinity

Keep infinity (keep_infinity): Pass true to prevent `Infinity` from being compressed into `1/0`, which may cause performance issues on `Chrome`.


Loops (loops): Optimizations for `do`, `while` and `for` loops when we can statically determine the condition.


Module (module): Pass `true` when compressing an ES6 module. Strict mode is implied and the `toplevel` option as well.

Negate IIFE

Negate IIFE (negate_iife): Negate `Immediately-Called Function Expressions` where the return value is discarded, to avoid the parens that the code generator would insert.


Passes (passes): The maximum number of times to run compress. In some cases more than one pass leads to further compressed code. Keep in mind more passes will take more time.


Properties (properties): Rewrite property access using the dot notation, for example `foo["bar"]` -> `foo.bar`.

Pure functions

Pure functions (pure_funcs): You can pass an array of names and Terser will assume that those functions do not produce side effects. DANGER: will not check if the name is redefined in scope. An example case here, for instance `var q = Math.floor(a/b)`. If variable `q` is not used elsewhere, Terser will drop it, but will still keep the `Math.floor(a/b)`, not knowing what it does. You can pass `pure_funcs: [ 'Math.floor' ]` to let it know that this function won't produce any side effect, in which case the whole statement would get discarded. The current implementation adds some overhead (compression will be slower).

Pure getters

Pure getters (pure_getters): If you pass `true` for this, Terser will assume that object property access (e.g. `foo.bar` or `foo["bar"]`) doesn't have any side effects. Specify `"strict"` to treat `foo.bar` as side-effect-free only when `foo` is certain to not throw, i.e. not `null` or `undefined`.
  • Disabled

  • Enabled

  • Strict

Reduce variables

Reduce variables (reduce_vars): Improve optimization on variables assigned with and used as constant values.

Reduce functions

Reduce functions (reduce_funcs): Allows single-use functions to be inlined as function expressions when permissible allowing further optimization. Enabled by default. Option depends on `reduce_vars` being enabled. Some code runs faster in the Chrome V8 engine if this option is disabled. Does not negatively impact other major browsers.


Sequences (sequences): Join consecutive simple statements using the comma operator. May be set to a positive integer to specify the maximum number of consecutive comma sequences that will be generated. If this option is set to `true` then the default `sequences` limit is `200`. Set option to `false` or `0` to disable. The smallest `sequences` length is `2`. A `sequences` value of `1` is grandfathered to be equivalent to `true` and as such means `200`. On rare occasions the default sequences limit leads to very slow compress times in which case a value of `20` or less is recommended.

Side effects

Side effects (side_effects): Remove expressions which have no side effects and whose results aren't used.


Switches (switches): De-duplicate and remove unreachable `switch` branches.


Toplevel (toplevel): Drop unreferenced functions (`"funcs"`) and/or variables (`"vars"`) in the top level scope (`false` by default, `true` to drop both unreferenced functions and variables).

Top retain

Top retain (top_retain): prevent specific toplevel functions and variables from `unused` removal (can be array, comma-separated, RegExp or function. Implies `toplevel`)


Typeofs (typeofs): Transforms `typeof foo == "undefined"` into `foo === void 0`. Note: recommend to set this value to `false` for IE10 and earlier versions due to known issues.

Apply unsafe transformations

This is an unsafe option: Enabling this may result in unexpected results.Apply unsafe transformations (unsafe): Apply "unsafe" transformations. See below


This is an unsafe option: Enabling this may result in unexpected results.Arrows (unsafe_arrows): Convert ES5 style anonymous function expressions to arrow functions if the function body does not reference `this`. Note: it is not always safe to perform this conversion if code relies on the the function having a `prototype`, which arrow functions lack. This transform requires that the `ecma` compress option is set to `2015` or greater.


This is an unsafe option: Enabling this may result in unexpected results.Compressions (unsafe_comps): Reverse `<` and `<=` to `>` and `>=` to allow improved compression. This might be unsafe when an at least one of two operands is an object with computed values due the use of methods like `get`, or `valueOf`. This could cause change in execution order after operands in the comparison are switching. Compression only works if both `comparisons` and `unsafe_comps` are both set to `true`.


This is an unsafe option: Enabling this may result in unexpected results.Function (unsafe_Function): Compress and mangle `Function(args, code)` when both `args` and `code` are string literals.


This is an unsafe option: Enabling this may result in unexpected results.Math (unsafe_math): Optimize numerical expressions like `2 * x * 3` into `6 * x`, which may give imprecise floating point results.


This is an unsafe option: Enabling this may result in unexpected results.Symbols (unsafe_symbols): Removes keys from native Symbol declarations, e.g `Symbol("kDog")` becomes `Symbol()`.

Unsafe methods

This is an unsafe option: Enabling this may result in unexpected results.Unsafe methods (unsafe_methods): Converts `{ m: function(){} }` to `{ m(){} }`. `ecma` must be set to `6` or greater to enable this transform. If `unsafe_methods` is a RegExp then key/value pairs with keys matching the RegExp will be converted to concise methods. Note: if enabled there is a risk of getting a "`<method name>` is not a constructor" TypeError should any code try to `new` the former function.


This is an unsafe option: Enabling this may result in unexpected results.Prototypes (unsafe_proto): Optimize expressions like `Array.prototype.slice.call(a)` into `[].slice.call(a)`.

Regular expressions

This is an unsafe option: Enabling this may result in unexpected results.Regular expressions (unsafe_regexp): Enable substitutions of variables with `RegExp` values the same way as if they are constants.


This is an unsafe option: Enabling this may result in unexpected results.Undefined (unsafe_undefined): Substitute `void 0` if there is a variable named `undefined` in scope (variable name will be mangled, typically reduced to a single character).


Unused (unused): Drop unreferenced functions and variables (simple direct variable assignments do not count as references unless set to `"keep_assign"`).

Mangling settings


Eval (eval): Pass `true` to mangle names visible in scopes where `eval` or `with` are used.

Keep class names

Keep class names (keep_classnames): Pass `true` to not mangle class names. Pass a regular expression to only keep class names matching that regex. See also: the `keep_classnames` compress option.

Keep function names

Keep function names (keep_fnames): Pass `true` to not mangle function names. Pass a regular expression to only keep function names matching that regex. Useful for code relying on `Function.prototype.name`. See also: the `keep_fnames` compress option.


Module (module): Pass `true` an ES6 modules, where the toplevel scope is not the global scope. Implies `toplevel`.


Reserved (reserved): Pass an array of identifiers that should be excluded from mangling. Example: `["foo", "bar"]`.


Toplevel (toplevel): Pass `true` to mangle names declared in the top level scope.

Safari 10

Safari 10 (safari10): Pass `true` to work around the Safari 10 loop iterator bug "Cannot declare a let variable twice". See also: the `safari10` format option.

Format settings

ASCII only

ASCII only (ascii_only): Escape Unicode characters in strings and regexps (affects directives with non-ascii characters becoming invalid).


Braces (braces): Always insert braces in `if`, `for`, `do`, `while` or `with` statements, even if their body is a single statement.


Comments (comments): by default it keeps JSDoc-style comments that contain "@license", "@preserve" or start with `!`, pass `true` or `"all"` to preserve all comments, `false` to omit comments in the output, a regular expression string (e.g. `/^!/`) or a function.
  • None

  • Some

  • All


ECMA (ecma): set desired EcmaScript standard version for output. Set `ecma` to `2015` or greater to emit shorthand object properties - i.e.: `{a}` instead of `{a: a}`. The `ecma` option will only change the output in direct control of the beautifier. Non-compatible features in your input will still be output as is. For example: an `ecma` setting of `5` will *not* convert modern code to ES5.
  • 5

  • 2015

  • 2016

  • 2017

  • 2018

  • 2019

  • 2020

Indentation level

Indent start

Indent start (indent_start): Prefix all lines by that many spaces.

Inline script

Inline script (inline_script): Escape HTML comments and the slash in occurrences of `</script>` in strings.

Keep quoted properties

Keep quoted properties (keep_quoted_props): When turned on, prevents stripping quotes from property names in object literals.

Max line length

Max line length (max_line_len): Maximum line length (for minified code).


Preamble (preamble): When passed it must be a string and it will be prepended to the output literally. The source map will adjust for this text. Can be used to insert a comment containing licensing information, for example.

Quote keys

Quote keys (quote_keys): pass `true` to quote all keys in literal objects

Quote style

Quote style (quote_style): Preferred quote style for strings (affects quoted property names and directives as well).
  • Prefer double

  • Always single

  • Always double

  • Always original

Preserve annotations

Preserve annotations (preserve_annotations): Preserve [Terser annotations](https://github.com/terser/terser#annotations) in the output.

Safari 10

Safari 10 (safari10): Set this option to `true` to work around the [Safari 10/11 await bug](https://bugs.webkit.org/show_bug.cgi?id=176685). See also: the `safari10` mangle option.


Semicolons (semicolons): Separate statements with semicolons. If you pass `false` then whenever possible we will use a newline instead of a semicolon, leading to more readable output of minified code (size before gzip could be smaller; size after gzip insignificantly larger).


Shebang (shebang): Preserve shebang `#!` in preamble (bash scripts).


WebKit (webkit): Enable workarounds for WebKit bugs. PhantomJS users should set this option to `true`.


Wrap IIFE (wrap_iife): Pass `true` to wrap immediately invoked function expressions.

Wrap function arguments

Wrap function arguments (wrap_func_args): Pass `false` if you do not want to wrap function expressions that are passed as arguments, in parenthesis. See [OptimizeJS](https://github.com/nolanlawson/optimize-js) for more details.

Parsing settings

Bare returns

Bare returns (bare_returns): Support top level `return` statements

HTML5 comments


Shebang (shebang): Support `#!command` as the first line