refractor.yaml file is the primary configuration file for Refractor. It controls which obfuscation passes run, how they behave, and where output is written.
The configuration file is required. Refractor will fail if
refractor.yaml is missing, empty, or contains invalid YAML.Creating a Configuration File
Generate a starter template:refractor.yaml in your current directory with sensible defaults.
Configuration Structure
The configuration file has two main sections:refractor
Global settings: symbol map path, exclusions, and verbosity
passes
Enable/disable obfuscation passes and configure their behavior
Default Template
Here’s the complete default configuration generated byrefractor init:
Global Settings (refractor)
The refractor section configures global tool behavior.
symbol_map
Type: StringDefault:
symbol_map.json
Path where the symbol map JSON file will be written. The symbol map contains the mapping of obfuscated names back to their original identifiers.
exclude
Type: List<String>Default:
[]
List of glob patterns to exclude libraries from obfuscation. Useful for generated files that shouldn’t be obfuscated.
Exclusions apply only to project libraries. External dependencies are never obfuscated.
verbose
Type: boolDefault:
false
Enable detailed logging during obfuscation.
- Which libraries are being processed
- Symbol rename operations
- String encryption transformations
- Dead code insertions
Obfuscation Scope
Refractor’s obfuscation scope is fixed to the current project:- Libraries matching the
nameinpubspec.yaml - Files under the working directory
Pass Configuration (passes)
The passes section controls which obfuscation transformations run and how they behave.
Pass Syntax
Each pass supports three configuration styles:If a pass is missing from the configuration, it’s treated as disabled.
Available Passes
rename
Rewrites class, method, and field identifiers to short, meaningless names.
Options:
preserve_main(bool, default:true)
Keep themain()function name unchanged. Set tofalseto obfuscate it.
string_encrypt
Replaces string literals with XOR-encoded byte arrays and injects a runtime decoder.
Options:
-
xor_key(int, default:0x5A)
XOR key for string encryption. Must be a valid byte value (0x00-0xFF). -
exclude_patterns(List<String>, default:[])
Regular expressions to exclude strings from encryption. Useful for URLs, file paths, or configuration strings.
dead_code
Inserts unreachable branches and statements to hinder static analysis and decompilers.
Options:
max_insertions_per_procedure(int, default:2)
Maximum number of dead code blocks to insert per function/method.
Complete Example
Production-ready configuration with all passes enabled:Validation and Error Handling
Refractor validates the configuration file at startup:File existence
Checks if
refractor.yaml exists in the current directory.Error: Configuration file not found: refractor.yamlFix: Run refractor init to create it.YAML syntax
Parses the YAML structure.Error:
Invalid configuration YAMLFix: Check for syntax errors (indentation, quotes, colons).Common Errors
Configuration YAML is empty
Configuration YAML is empty
The file exists but has no content.Fix: Add at least a minimal configuration:
Unknown pass: pass_name
Unknown pass: pass_name
You referenced a pass that doesn’t exist.Fix: Valid pass names are:
rename, string_encrypt, dead_code.Configuration root must be a YAML mapping/object
Configuration root must be a YAML mapping/object
The file doesn’t have a proper YAML structure.Fix: Start with
refractor: and passes: top-level keys.Field Naming Convention
All configuration fields use snake_case (e.g.,
preserve_main, xor_key, symbol_map).analysis_options.yaml).
Related Pages
Symbol Map
Learn about the obfuscation mapping file
Library Exclusions
Exclude files from obfuscation