Jinja2 Template Tester
Test Jinja2 network config templates live in your browser. Paste a template and JSON data — get the rendered config instantly, no Python or Ansible required.
Live Preview
Renders as you type — 400ms debounce so results appear instantly without lag
Ansible-Compatible
Same Jinja2 syntax used in Ansible, Nornir, SaltStack, and Netmiko templates
40+ Filters
upper, lower, join, sort, default, tojson, indent, groupby and more — all the common network automation filters
Ctrl+Enter to render · Live render on input
Rendered Output
Output will appear here... Supported Jinja2 features
{{ var }} {{ obj.key }} {{ arr[0] }}
{% for x in list %} {% if cond %} {% set x = val %}
loop.index loop.first loop.last loop.length
Filters: upper lower default join replace sort length int float tojson ...
Not supported: extends, include, macros, custom filters, XPath expressions.
Jinja2 for Network Automation
Common Template Patterns
Conditional interface shutdown
{% if intf.enabled %}
no shutdown
{% else %}
shutdown
{% endif %}
BGP neighbors loop
{% for n in bgp_neighbors %}
neighbor {{ n.ip }} remote-as {{ n.asn }}
{% endfor %}
Default filter for optional vars
description {{ intf.desc | default("No desc") }}
Useful Filters for Network Configs
| Filter | Use case |
|---|---|
| upper / lower | Normalize hostname case |
| default('x') | Fall back if var is undefined |
| join(',') | Build comma-separated community lists |
| sort | Sort neighbor IPs before generating config |
| int / float | Convert string values from APIs |
| tojson | Embed data as JSON in RESTCONF payload |
| indent(2) | Indent multi-line descriptions |
| groupby('vlan') | Group interfaces by VLAN |
Frequently Asked Questions
Why is Jinja2 important for network automation?
Jinja2 is the default templating engine for Ansible, Nornir, and SaltStack. Network engineers use it to generate device-specific configurations from a single template and a data source (inventory, IPAM export, YAML vars file). Instead of maintaining one config per device, you maintain one template and a structured data file. This tool lets you test templates interactively before running them against real devices.
What Jinja2 features does this tool support?
This tool supports: variable substitution ({{ var }}, {{ obj.key }}, {{ arr[0] }}), for loops ({% for x in list %}/{% endfor %}), if/elif/else blocks, set statements ({% set x = value %}), comments ({# ... #}), the loop variable (loop.index, loop.first, loop.last, loop.length), and over 40 filters including upper, lower, default, join, replace, sort, length, int, float, tojson, truncate, indent, groupby, and more.
Why does this tool use JSON instead of YAML for the context data?
JSON is unambiguous to parse in the browser without a dependency, and is directly compatible with Ansible's variable format when you use 'vars_files' with JSON files or query APIs. If your data is in YAML (Ansible group_vars, host_vars), you can convert it with: python3 -c "import yaml,json,sys; print(json.dumps(yaml.safe_load(sys.stdin.read())))" < your_file.yml
What Jinja2 features are NOT supported?
This tool does not support: template inheritance ({% extends %}, {% block %}), {% include %}, custom Jinja2 extensions, the Ansible-specific filters (ipaddr, combine, selectattr with complex tests), macros ({% macro %}), the 'namespace' object for cross-scope variable modification, and Ansible's special variables (inventory_hostname, groups, hostvars). For production Ansible testing, use 'ansible-playbook --check' or the ansible-lint tool.
How do I use loop.index and loop.first in a for loop?
Inside a {% for %} block, the 'loop' object provides: loop.index (1-based position), loop.index0 (0-based), loop.first (true on first iteration), loop.last (true on last), loop.length (total items), loop.revindex (reverse 1-based), loop.revindex0 (reverse 0-based). Example: {% if not loop.first %}!{% endif %} to add a separator between items but not before the first one.
Can I use this to generate Cisco, Juniper, or Arista configs?
Yes. The Load Example button shows a realistic Cisco IOS interface configuration template. The same approach works for Juniper (JunOS set commands or JSON-format), Arista EOS (CLI or eAPI JSON), Nokia SR-OS, and any text-based config format. The template syntax is identical to what Ansible and Nornir use, so templates tested here will work directly in your playbooks and scripts.
Related Network Automation Tools
YANG Module Checker
Validate YANG module syntax and explore node trees for NETCONF/RESTCONF automation.
DSCP / QoS Converter
Convert DSCP values to use in Jinja2 QoS policy templates for Cisco and Juniper.
Route Summarization
Find optimal summary routes to use in your BGP prefix-list Jinja2 templates.
Wildcard Mask Calculator
Calculate wildcard masks for ACL Jinja2 templates on Cisco IOS devices.