init command scaffolds a refractor.yaml configuration file with sensible defaults and inline documentation. This file is required for all Refractor operations.
Usage
Options
Output path for the config file. By default, creates
refractor.yaml in the current directory.Short flag: -oBehavior
Check for Existing File
If a file already exists at the output path, Refractor will prompt you to confirm whether to overwrite it.
Write Template
Creates the configuration file with a complete template including all available passes and their options.
Generated Template
Theinit command creates a fully-commented configuration template:
Configuration Sections
Global Settings (refractor)
Path where the symbol mapping file will be written. This JSON file maps obfuscated names back to their originals for debugging.
Glob patterns to exclude libraries from obfuscation. Useful for generated files like
*.g.dart or *.freezed.dart.Example:Enable detailed logging during the build process.
The obfuscation scope is always the current project: libraries matching the
name in pubspec.yaml and files under the working directory.Pass Configuration (passes)
Each pass can be configured in three ways:
true- Enable with default settingsfalse- Disable the passmap- Enable with custom options
Rename Pass
Rewrites class, method, and field identifiers to short meaningless names.Keep the
main() function name unchanged. Recommended for executables.String Encryption Pass
Replaces string literals with XOR-encoded byte arrays and injects a runtime decoder.Byte value used for XOR encryption. Valid range:
0x00 to 0xFF.Regex patterns for strings that should not be encrypted. Useful for preserving URLs, package names, or other runtime-critical strings.
Dead Code Pass
Inserts unreachable branches to hinder static analysis and decompilers.Maximum number of dead code branches to insert per function.
Examples
Create Default Config
refractor.yaml in the current directory.
Custom Output Path
config/ subdirectory.
Monorepo Setup
refractor.yaml configuration.
Output
On success:After creating your config file, customize the pass settings based on your project’s needs. Not all passes are suitable for every application.
Next Steps
After initializing your configuration:Review Pass Settings
Uncomment and customize the passes you want to enable. Start with just
rename and string_encrypt for most projects.Configure Exclusions
Add glob patterns to exclude generated files or third-party code that shouldn’t be obfuscated.
Related Commands
refractor build
Compile and obfuscate your application
Configuration Guide
Detailed configuration reference