skillfed

jinja2-humanize-extension

a jinja2 extension to use humanize library inside jinja2 templates

jinja2-humanize-extension v0.4.0 6.4M downloads/30d#1,921 on PyPI6
Permissive license BSD Active released

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-extension

uv

uv add jinja2-humanize-extension

poetry

poetry add jinja2-humanize-extension

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseProgramming Language :: Python :: 3

Tags

jinja2 humanize filtershuman readable formatting templatesjinja2 date time formattingfile size formatting jinja2number formatting templateshumanize jinja2 extensionnatural language template filters
jinja2-extensiontemplate-filtersnumber-formatting

More Text Processing packages