Jinja2 template tester running entirely in your browser using Nunjucks — a JavaScript implementation of Jinja2. Supports variables, loops, conditionals, filters, macros, and more. Perfect for testing Ansible templates, Nornir configs, or any Jinja2-based network automation.
Jinja2 Template
Variables
YAML
Network Automation Examples (click to load)
{{ var }}Print variable
{% if x %}Conditional block
{% elif x %}Else-if branch
{% else %}Else branch
{% endif %}End conditional
{% for x in list %}Loop over list
{% endfor %}End loop
loop.indexLoop counter (1-based)
loop.index0Loop counter (0-based)
loop.firstTrue on first iteration
loop.lastTrue on last iteration
{% set x = val %}Set variable
{% macro m(a) %}Define macro
{# comment #}Comment (not rendered)
x is definedTest if var is defined
x is not definedTest if undefined
{{ x | upper }}Uppercase
{{ x | lower }}Lowercase
{{ x | default(‘val’) }}Default if undefined
{{ x | join(‘, ‘) }}Join list with separator
{{ x | length }}Length of string/list
{{ x | int }}Convert to integer
{{ x | string }}Convert to string
{{ x | replace(‘a’,’b’) }}Replace substring
{{ x | trim }}Strip whitespace
{{ x | first }}First element
{{ x | last }}Last element
{{ x | list }}Convert to list
{{ x | sort }}Sort list
{{ x | unique }}Remove duplicates
{{ x | selectattr(‘k’) }}Filter objects by attr
{{ x | map(attr=’k’) }}Extract attribute
{% if intf.enabled %}Check boolean flag
{% if vlan_id is defined %}Optional config block
{% for vlan in vlans | sort %}Sort VLANs in loop
{% if not loop.last %}Add separator between items
{{ desc | default(‘–‘) }}Fallback for missing desc
{% set ns = namespace(x=0) %}Mutable var in loop
{{ peer | upper }}Normalise peer name
{% for k,v in dict.items() %}Loop over dict key/value