skillfed

jinja2-ansible-filters

A port of Ansible's jinja2 filters without requiring ansible core.

jinja2-ansible-filters v1.3.2 2.1M downloads/30d#3,330 on PyPI
Copyleft license GPL3 Abandoned released

What it is and what it does

This package extracts and ports Ansible's Jinja2 template filters into a standalone library, so you can use Ansible-style filtering in any Jinja2 template without installing the full Ansible framework. It includes filters for common operations: base64 encoding/decoding, file path manipulation (basename, dirname, realpath), hashing (md5, sha1, checksum), JSON and YAML conversion, regex operations, and utility filters like type checking and UUID generation. A few filters with heavy Ansible dependencies (combine, get_encrypted_password, dict2items, items2dict) are excluded, and two filters (groupby, random) are prefixed with ans_ to avoid collisions with Jinja2 builtins.

The package is a thin extension layer that registers these filters as a Jinja2 extension, so you load it by passing AnsibleCoreFiltersExtension to your Environment. It depends only on Jinja2 and PyYAML, making it lightweight to add to projects that already use those libraries. However, the project has been abandoned since 2022-06-30 with no maintenance activity, so compatibility with newer Jinja2 releases is not guaranteed beyond what was tested at version 1.3.2.

Use it for:

  • Use it to port Ansible playbook templates to standalone Jinja2 rendering without Ansible as a runtime dependency.
  • Use it in cookiecutter templates to access Ansible-style filters for file path and data transformation during project scaffolding.
  • Use it to add base64, JSON, YAML, and regex filters to Jinja2 environments in configuration management or templating pipelines.
  • Use it to perform hashing and encoding operations (md5, sha1, b64encode) directly in templates without custom filter registration.
  • Use it in static site generators or documentation tools that use Jinja2 and need Ansible-compatible filter semantics.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a collection of Jinja2 template filters ported from Ansible, including encoding, hashing, path manipulation, JSON/YAML conversion, and regex operations, without requiring Ansible core.

Yes, if you need Ansible-style Jinja2 filters and can accept the GPL3 copyleft license. The package is lightweight, has low install friction, and works well for template-heavy projects. However, do not install if your project is proprietary or closed-source (GPL3 is a blocker), or if you require active maintenance and compatibility updates—the project is abandoned and has not been updated since 2022-06-30. Test compatibility with your current Jinja2 version before relying on it in production.

Install

jinja2-ansible-filters on PyPI

pip

pip install jinja2-ansible-filters

uv

uv add jinja2-ansible-filters

poetry

poetry add jinja2-ansible-filters

Installing jinja2-ansible-filters

Before you install

Installation is straightforward with low friction; the package has only two runtime dependencies (Jinja2 and PyYAML). However, the project is marked as abandoned with no releases since 2022-06-30, which means bug fixes and compatibility updates are unlikely.

License in practice

The package is released under GPL3 (copyleft), which means any code that incorporates or distributes this package must also be released under compatible open-source terms. This is a significant constraint for proprietary or closed-source projects.

Quickstart

from jinja2 import Environment
from jinja2_ansible_filters import AnsibleCoreFiltersExtension

env = Environment(extensions=[AnsibleCoreFiltersExtension])
template = env.from_string('{{ "hello" | b64encode }}')
result = template.render()

Requires Jinja2 and PyYAML to be installed; compatibility with Jinja2 versions 3.1+ requires the environmentfilter-to-pass_environment rename, which is included in version 1.3.1+.

Verify before relying

  • Whether the package remains compatible with current Jinja2 and PyYAML versions beyond what version 1.3.2 tested.
  • Whether the GPL3 license applies to the entire codebase or only portions derived from Ansible (the description mentions both GPL3 and BSD).
  • Performance characteristics or memory overhead when using the full filter set in high-volume templating scenarios.
  • Total number of filters provided by the package across all categories.

Package facts

License GPL3 (copyleft)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 2 — Jinja2, PyYAML
Maintenance abandoned — 1,506 days since the last release
First released
Downloads 2,061,330/month — #3,330 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: jinja2_ansible_filters-1.3.2-py3-none-any.whl

Tags

jinja2 ansible filterstemplate filters for jinja2ansible-style jinja2 extensionsjinja2 yaml json filtersjinja2 encoding hashing filtersjinja2 path manipulationjinja2 regex filters
jinja2-extensiontemplate-filtersansible-compatible

More Text Processing packages