Template validation ensures your Nuclei templates follow correct syntax and include all required fields. Nuclei provides built-in validation tools to catch errors before runtime.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.
Why validate templates?
Validation catches common issues:Syntax errors
YAML formatting issues, indentation problems, and invalid field types
Missing fields
Required metadata like
id, name, and authorInvalid values
Incorrect severity levels, malformed regex patterns, or invalid protocol configurations
Structural issues
Conflicting protocol declarations or incorrect field combinations
Validation methods
Command-line validation
The primary way to validate templates is using the-validate flag:
- Single template
- Directory
- Multiple templates
Validate a specific template file:Successful output:
Build-time validation
For development, use the Makefile target:This builds the nuclei binary and validates templates as shown in
CONTRIBUTING.md and CLAUDE.md.Validation rules
Mandatory field validation
Templates must include specific required fields. The validation logic inpkg/templates/parser_validate.go:13-37 enforces:
Optional field warnings
Some fields trigger warnings when missing (frompkg/templates/parser_validate.go:49-65):
YAML syntax validation
Nuclei supports both strict and non-strict YAML parsing:- Strict mode (default)
- Non-strict mode
Strict mode rejects unknown fields and requires exact syntax:This catches typos and invalid fields:
Validation errors
Common error messages
mandatory field is missing
mandatory field is missing
Error message:Cause: Required metadata fields are not present.Solution: Add the missing fields to the
info section:invalid field format for 'id'
invalid field format for 'id'
Error message:Cause: Template ID contains invalid characters or format.Solution: Use only lowercase letters, numbers, hyphens, and underscores:
failed to parse PEM block
failed to parse PEM block
Error message:Cause: YAML indentation errors or invalid structure.Solution: Check indentation (use 2 spaces, no tabs):
use http or requests, both are not supported
use http or requests, both are not supported
Error message:Cause: Template uses both deprecated
requests and new http fields.Solution: Use only http (from pkg/templates/templates.go:362-364):unknown field
unknown field
Error message:Cause: Misspelled field name or incorrect indentation.Solution: Check field spelling and indentation:
Debugging validation failures
When validation fails:Parser configuration
The template parser can be configured programmatically (frompkg/templates/parser.go:21-54):
Validation statistics
Nuclei tracks validation statistics internally:- SyntaxErrorStats: Count of templates with syntax errors
- SyntaxWarningStats: Count of templates with warnings
pkg/templates/parser.go:107-120.
Template format support
Nuclei supports multiple template formats:- YAML (recommended)
- JSON
Standard format with preprocessing support:
Validation best practices
Pre-commit validation
Integrate validation into your development workflow:CI/CD integration
Add validation to your CI pipeline:.github/workflows/validate.yml
Editor integration
Use editor plugins for real-time validation:VS Code
Install YAML extension for syntax highlighting and validation
IntelliJ/PyCharm
Built-in YAML support with schema validation
Validation workflow
Recommended workflow for template development:Template loading errors
Validation can catch issues during template loading:Next steps
Template signing
Learn about signing templates for security
Best practices
Follow guidelines for high-quality templates
Contributing
Submit validated templates to the community
Template structure
Understand template components in detail