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

Quota

javascript-obfuscator 5.9.0 or later reads the usage left on your plan with getProQuota, so a build can check that its files fit before it starts instead of failing partway. A build counts the size of its source in bytes (UTF-8), and at least minBytesPerBuild; the size of the output does not count. When a build is refused because a limit is used up, the thrown ApiError has code set to dailyLimit or monthlyLimit, and that window's resetsAt says when it starts over. Every field is described in the API Reference.

Node.js (.mjs) with a quota check

JavaScript

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 can name the same alias in the obfuscate request's optionsPreset, and the server resolves it the same way. To read a preset's options without obfuscating, use the presets endpoint. Both 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