django-markdownify
Markdown template filter for Django.
What it is and what it does
Django Markdownify is a template filter that processes Markdown syntax into HTML within Django templates, automatically sanitizing the output using bleach to prevent injection attacks. It wraps the markdown and bleach libraries, allowing you to write `{{ text|markdownify }}` in templates to render user-supplied or content-managed Markdown safely.
The package supports multiple configuration profiles, so you can define different whitelist tags and markdown extensions for different use cases—for example, one profile for user comments (restrictive) and another for documentation (permissive). Settings are defined in Django's settings.py and referenced by name in templates. It has been maintained since 2016 and remains actively developed.
Use it for:
- Render user-submitted comments or forum posts as HTML while restricting dangerous tags and scripts.
- Display documentation or help text written in Markdown within Django admin or frontend templates.
- Convert content-managed Markdown fields (e.g., from a CMS) to HTML with site-specific tag whitelists.
- Build blog or news sites where authors write in Markdown and the template layer handles HTML conversion.
- Sanitize Markdown from external APIs or feeds before displaying in Django templates.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Django template filter that converts Markdown text to sanitized HTML, wrapping the markdown and bleach libraries for safe rendering in templates.
Yes. The package is actively maintained, has low install friction, carries a permissive MIT license, and solves a common Django need—rendering Markdown safely in templates. No known vulnerabilities and a stable dependency set make it a straightforward choice for projects that need template-level Markdown conversion.
Install
django-markdownify on PyPI
pip
pip install django-markdownifyuv
uv add django-markdownifypoetry
poetry add django-markdownifyInstalling django-markdownify
Before you install
Low friction install with three straightforward runtime dependencies (Django, markdown, bleach). Active maintenance with a recent release in May 2026 and consistent repository activity.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
# In Django settings.py, configure if needed:
MARKDOWNIFY = {"default": {"WHITELIST_TAGS": ["a", "p"]}}
# In your template:
{% load markdownify %}
{{ mytext|markdownify }}
# Or with an alternative configuration:
{{ mytext|markdownify:"alternative" }}
Requires Django to be installed and configured; the filter only works within Django template contexts.
Verify before relying
- Whether the package handles edge cases in markdown-to-HTML conversion beyond what markdown and bleach provide by default
- Performance characteristics when processing large volumes of markdown text in templates
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — Django, markdown, bleach |
| Maintenance | actively maintained — 88 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 154,728/month — #10,846 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_markdownify-0.9.7-py3-none-any.whl
Tags
More HTML packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
markdownifyConverts HTML to Markdown, with fine-grained…
permissive · top 1,000 on PyPI
django-bleachIntegrates bleach HTML sanitization into Django…
permissive · top 15,000 on PyPI
django-mathfiltersProvides Django template filters for basic…
permissive · top 15,000 on PyPI
bleachBleach sanitizes untrusted HTML by escaping or…
permissive · top 1,000 on PyPI
markdown2Converts Markdown text to HTML using a fast,…
permissive · top 5,000 on PyPI
bleach-allowlistProvides curated allowlists of HTML tags,…
permissive · top 5,000 on PyPI
html-sanitizerSanitizes HTML fragments by enforcing an…
permissive · top 5,000 on PyPI
django-settings-exportProvides a Django template context processor…
permissive · top 15,000 on PyPI
nh3nh3 sanitizes HTML by removing unsafe tags and…
permissive · top 1,000 on PyPI
telegramify-markdownConverts Markdown to Telegram plain text with…
permissive · top 15,000 on PyPI