transforms.mangleProperties. Passing true selects every eligible non-built-in property. An options object lets you restrict that property selection.
obfuscate.mjs
Choose a selection strategy
- Naming rule
- Annotations
- Reviewed cache
Use
regex for a private naming convention. This example selects names ending in _ and reserves one public exception.Regex selection
Roll it out safely
1
Find every use
Identify every file, caller, serialized value, and runtime lookup that can read the selected properties.
2
Select a narrow set
Start with a private naming rule, explicit annotations, or a reviewed cache. Do not begin with
mangleProperties: true across a public interface.3
Reserve external names
Add framework hooks, serialized keys, public methods, and reflective lookups to
reserved.4
Share mappings across files
Reuse one
Map<string, string> through cache when separately obfuscated files exchange selected properties.5
Test external consumers
Run integration tests against the obfuscated artifacts, including consumers that are not part of the input string.
builtins
Type: booleanDefault:
false
Reserves known JavaScript and DOM property names when false.
Setting
builtins: true can rename runtime or browser APIs such as collection methods and DOM properties. Use it only when those names cannot refer to platform objects.cache
Type: Map<string, string>Default: a new map for the call Reuses mappings across calls and receives new mappings. Keys and values must be strings. Outputs must be unique and cannot be
__proto__, constructor, or prototype.
Shared cache
debug
Type: boolean | stringDefault:
false
Keeps the source name visible. true produces _$source$_. A value such as debug: 'DEV' produces _$source$DEV_. Collisions fall back to the configured generator.
keepQuoted
Type: boolean | 'strict'Default:
false
nameGenerator
Type: (index: number) => stringDefault: the configured string generator Receives a zero-based ordinal for each candidate and takes precedence over
stringGeneratorMode. It must eventually return an available, nonnumeric string. The transform throws after 100,000 rejected candidates.
onlyAnnotated
Type: booleanDefault:
false
Limits mangling to names marked with the exact standalone comment /*@__MANGLE_PROP__*/ or /*#__MANGLE_PROP__*/. Mark standalone property strings with the exact comment /*@__KEY__*/ or /*#__KEY__*/. Annotations bypass regex, but not reserved, and never appear in the generated output.
onlyCache
Type: booleanDefault:
false
Limits selection to source names already in cache.
regex
Type: RegExp | stringDefault: all eligible names Selects matching names. Strings are compiled with
new RegExp(value). The transform resets lastIndex before each test. Numeric names are never selected.
reserved
Type: readonly string[]Default:
[]
Excludes source names and prevents the generator from emitting them. It takes precedence over regex, annotations, and cache selection.
stringGeneratorMode
Type: a string generator modeDefault: the top-level mode Overrides the top-level mode for property names.
nameGenerator takes precedence.
undeclared
Type: booleanDefault:
false
Includes unquoted accesses rooted at undeclared identifiers. Bracket-string accesses are candidates either way.
Names that always stay unchanged
The transform retains private class names, class constructor syntax, object-literal__proto__ setters, and names that would collide with retained properties.
Mangle-properties transform
See the transform’s behavior and a before-and-after example.
Configure transforms
Fit property mangling into a complete
ObfuscatorOptions object.