Documentation
/
VM Obfuscation
/

Using the NPM Package

Using the NPM Package

Pro

Watch

Using the Obfuscator.io API: API Keys, npm Package, CLI and Custom Presets

Watch on YouTube

The package sends the build to the obfuscator.io API, so it needs an API key (Pro, Team, or Business) passed as apiToken, or --pro-api-token on the CLI. Creating keys, team service tokens, and keeping them out of browser code are covered in the API Reference.

API Keys

npm

Bash

production.json

JSON

Node.js (.mjs)

Code

CLI

Code

Custom presets

Keep the configuration in the dashboard instead of in a config file: save the current options as a custom preset, give it an API alias in the save dialog, and set optionsPreset to that alias. javascript-obfuscator 5.8.0 or later fetches the preset before obfuscating, so changing the preset in the dashboard changes the next build and nothing in the repository needs a commit. The preset's options are the base; anything else you pass overrides them, the same way built-in presets are merged. A team service token resolves the team owner's presets. A member's API key resolves their own presets plus the ones the owner shared with the team.

Node.js (.mjs) with a preset

Code

CLI with a preset

Code

"optionsPreset": "production" in production.json does the same for a --config build. Built-in names such as vm-default are never looked up as aliases. An alias you do not have fails with HTTP 404 before any source is sent, and a custom preset with no Pro feature enabled is obfuscated locally with its options.

The preset over REST

A direct REST integration fetches the preset's options from the presets endpoint in a separate request and sends them as the obfuscate request's options. Both endpoints are documented in the API Reference. The javascript-obfuscator package fetches the preset once per run, and that request counts toward the same per-user rate limit as obfuscation requests.

Rate limits and large-upload behavior are described in the API Reference, and your plan limits are shown in the dashboard; the package switches to temporary uploads for large sources automatically on Team and Business plans.

Testing and CI · API Reference