developers.do

JavaScript Obfuscator

Shorten JavaScript variable and function names and compact the code directly in your browser.

Enable both options to rename top-level functions.

Turn this off if other scripts use the file’s global names.

Guide

About this javascript obfuscator

The JavaScript Obfuscator parses a pasted function, script, or module, replaces eligible variable and function names with shorter identifiers, and removes unnecessary whitespace and ordinary comments. The transformation runs in a browser worker, and pasted code stays on your device.

How to use the javascript obfuscator

  1. 1.Paste a function, open a local JavaScript file, or select Load example to try three connected modules one file at a time.
  2. 2.Function and top-level renaming are on by default. Turn off either option to preserve those names.
  3. 3.Select Obfuscate, then copy or download the output. Downloaded modules keep their filenames so relative imports still resolve.

Important details

Which names are preserved?

Object property names, public module export names, and import paths are preserved. A default import’s local name can be shortened, as shown in the example. For a named import, the dependency’s exported name stays in the import declaration and the local binding can be shortened. Turn off top-level renaming if other scripts use the file’s global names. Turn off function renaming if code depends on Function.name or you need the original names in stack traces.

How much does it hide?

Shorter names make code harder to read at a glance. Literal values remain available in the output, and anyone who receives the JavaScript can inspect it.

Frequently asked questions

Can I paste TypeScript or JSX?

Paste plain JavaScript. Compile TypeScript or JSX to JavaScript first.

Does the tool run the pasted code?

The tool parses and rewrites the code without executing it.

References: Terser API reference