Variables in Nuclei allow you to define reusable values, perform computations, and create dynamic template behavior. They can be defined at the template level, extracted from responses, or computed using DSL helper functions.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/projectdiscovery/nuclei/llms.txt
Use this file to discover all available pages before exploring further.
Variable types
Nuclei supports three types of variables:Template variables
Defined at the template level and available to all requests:Extracted variables
Extracted from responses using extractors and available in subsequent requests:Dynamic variables
Generated at runtime using payloads or helper functions:Built-in variables
Nuclei provides several built-in variables for common use cases:The input URL including protocol and port.Example:
https://example.com:443The hostname from the input URL.Example:
example.comAlias for
{{Hostname}}.The port from the input URL.Example:
443The path from the input URL.Example:
/api/v1/usersThe root URL without path.Example:
https://example.comThe URL scheme (http/https).Example:
httpsFully Qualified Domain Name.Example:
www.example.comGenerates a unique Interactsh URL for OOB testing.Example:
c59p8k2a0000kg8a0000hg.oast.funUsing variables in requests
- HTTP Headers
- Request Body
- URL Path
- DNS Queries
Variable scope
Variables have different scopes depending on where they’re defined:Global scope
Request scope
Extracted variables are available in subsequent requests:Computing variables
Use DSL helper functions to compute values:Variables support nested helper functions:
{{base64(to_lower(Host))}}Payloads as variables
Payloads create variables that iterate over values:Constants
Constants are scalar values that don’t support helper functions:Flow variables
In flow-based templates, use JavaScript to manipulate variables:Real-world examples
Variable precedence
When multiple variables have the same name, Nuclei follows this precedence (highest to lowest):- Flow-set variables (
set()function) - Extracted variables (from extractors)
- Payload variables
- Template variables
- Built-in variables
Best practices
- Use descriptive names - Choose clear, self-documenting variable names
- Minimize global variables - Keep variables scoped to where they’re needed
- Extract only what’s needed - Don’t extract large amounts of unnecessary data
- Use internal extractors - Mark intermediate values as internal
- Validate variable formats - Use matchers to verify extracted data
- Document complex variables - Add comments for computed or transformed values
- Avoid name collisions - Don’t reuse built-in variable names
Common patterns
Conditional variables
Timestamp-based variables
Encoded variables
Related
Extractors
Extract data from responses
Helper Functions
DSL helper functions
Flow Control
JavaScript-based flow
Payloads
Payload configuration