jinja2-humanize-extension
a jinja2 extension to use humanize library inside jinja2 templates
What it is and what it does
This package bridges Jinja2 templating and the humanize library by exposing humanize's formatting functions as Jinja2 filters. Instead of calling humanize functions in Python code before rendering, you can apply them directly in templates using a filter syntax like `{{ value|humanize_naturalsize() }}`. It currently maps functions for file sizes, dates, times, numbers, and localization settings.
The extension is lightweight—just two dependencies—and works with current Python versions. It's marked stable and actively maintained, though two functions (abs_timedelta and date_and_delta) are retained for compatibility despite being deprecated in humanize >= 4.0. Use it when you want template-level control over human-readable output formatting without pre-processing values in your application code.
Use it for:
- Format file sizes in web templates: {{ file.bytes|humanize_naturalsize() }} renders as '30.0 MB'.
- Display relative dates and times in UI: {{ event.timestamp|humanize_naturaltime() }} shows relative time.
- Localize number formatting in multilingual templates using humanize_thousands_separator() and humanize_decimal_separator().
- Render ordinal numbers in templates: {{ rank|humanize_ordinal() }} produces ordinal forms.
- Apply scientific or metric notation to large numbers directly in Jinja2 without backend logic.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds humanize library filters to Jinja2 templates, enabling human-readable formatting of numbers, dates, times, and file sizes directly in template expressions.
Yes. Low install friction, no known vulnerabilities, permissive license, and active maintenance make it safe. Install if you use Jinja2 templates and want to apply humanize formatting directly in templates rather than preprocessing values in Python—especially useful for web applications and report generation where template-level control over number and date presentation matters.
Install
jinja2-humanize-extension on PyPI
pip
pip install jinja2-humanize-extensionuv
uv add jinja2-humanize-extensionpoetry
poetry add jinja2-humanize-extensionInstalling jinja2-humanize-extension
Before you install
Low friction: pure Python wheel with only two runtime dependencies (jinja2 and humanize). Marked Production/Stable with active maintenance; last commit 2026-07-08.
License in practice
BSD permissive license allows commercial and private use with minimal restrictions.
Quickstart
from jinja2 import Environment
from jinja2_humanize_extension import HumanizeExtension
env = Environment(extensions=[HumanizeExtension])
template = env.from_string("{{ 30000000|humanize_naturalsize() }}")
print(template.render())
Verify before relying
- Whether all humanize functions remain compatible with humanize >= 4.0 beyond the two explicitly deprecated functions noted in the description.
- Performance characteristics when rendering templates with many humanize filters on large datasets.
- Exact output format for ordinal numbers and other functions across different locales.
Package facts
| License | BSD (permissive) |
| Python support | supports the current Python release (>=3.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — jinja2, humanize |
| Maintenance | actively maintained — 1,078 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,365,322/month — #1,921 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: jinja2_humanize_extension-0.4.0-py3-none-any.whl
Keywords: jinja2, extension
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
Flask-MomentFlask-Moment adds moment.js date and time…
permissive · top 15,000 on PyPI
jinja2-timeJinja2 extension that adds template tags for…
permissive · top 5,000 on PyPI
jinja2-ansible-filtersProvides a collection of Jinja2 template…
copyleft · top 5,000 on PyPI
jinja2-strcaseAdds string-case conversion filters to Jinja2…
permissive · top 15,000 on PyPI
humanizeConverts numbers, dates, times, and file sizes…
permissive · top 1,000 on PyPI
jinjanator-pluginsProvides the plugin API and hook decorators…
permissive · top 5,000 on PyPI
jinja2_pluralizeProvides Jinja2 template filters for…
permissive · top 15,000 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
jinja2-cliA command-line interface for Jinja2 templating…
permissive · top 5,000 on PyPI
reuters-styleFormats dates, numbers, and text according to…
permissive · top 15,000 on PyPI