The CLI for Jinja2.
$ jinja2 template.j2 data.json
$ curl -s http://api.example.com | jinja2 template.j2
$ uv tool install jinja2-cli
$ pip install jinja2-cli
Built-in: JSON, INI, ENV, querystring, TOML (Python 3.11+)
Optional formats via extras:
$ pip install jinja2-cli[yaml]
$ pip install jinja2-cli[xml]
$ pip install jinja2-cli[hjson]
$ pip install jinja2-cli[json5]
- Read data from files or stdin
- Define variables inline with
-D key=value - Custom Jinja2 extensions
- Import custom filters - see Custom Filters below
- Full control over Jinja2 environment options
Run jinja2 --help for all options, or see docs/ for full documentation.
Extend Jinja2 with your own filters or use Ansible's extensive filter library:
# Use custom filters
$ jinja2 template.j2 data.json -F myfilters
# Use Ansible filters
$ jinja2 template.j2 data.json -F ansible.plugins.filter.coreExample filter module:
# myfilters.py
def reverse(s):
return s[::-1]
def shout(s):
return s.upper() + "!"See docs/filters.md for complete documentation and examples.
- Dangerzone by Freedom of the Press Foundation
- Elastic Docker images (Logstash, Kibana, Beats)
- ScyllaDB CloudFormation templates
- 800+ more on GitHub