MarkupSafe
Safely add untrusted strings to HTML/XML markup.
Install
markupsafe on PyPI
pip
pip install markupsafeuv
uv add markupsafepoetry
poetry add markupsafePackage facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | aging — 320 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the 100 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: markupsafe-3.0.3-cp310-cp310-macosx_10_9_x86_64.whl; markupsafe-3.0.3-cp310-cp310-macosx_11_0_arm64.whl; markupsafe-3.0.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; markupsafe-3.0.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; markupsafe-3.0.3-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl; markupsafe-3.0.3-cp310-cp310-musllinux_1_2_aarch64.whl; markupsafe-3.0.3-cp310-cp310-musllinux_1_2_riscv64.whl; markupsafe-3.0.3-cp310-cp310-musllinux_1_2_x86_64.whl; markupsafe-3.0.3-cp310-cp310-win32.whl; markupsafe-3.0.3-cp310-cp310-win_amd64.whl; markupsafe-3.0.3-cp310-cp310-win_arm64.whl; markupsafe-3.0.3-cp311-cp311-macosx_10_9_x86_64.whl; markupsafe-3.0.3-cp311-cp311-macosx_11_0_arm64.whl; markupsafe-3.0.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; markupsafe-3.0.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; markupsafe-3.0.3-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl; markupsafe-3.0.3-cp311-cp311-musllinux_1_2_aarch64.whl; markupsafe-3.0.3-cp311-cp311-musllinux_1_2_riscv64.whl; markupsafe-3.0.3-cp311-cp311-musllinux_1_2_x86_64.whl; markupsafe-3.0.3-cp311-cp311-win32.whl
About MarkupSafe
from the package's own PyPI description — quoted content, verbatim
<div align="center"><img src="https://raw.githubusercontent.com/pallets/markupsafe/refs/heads/stable/docs/_static/markupsafe-name.svg" alt="" height="150"></div>
MarkupSafe
MarkupSafe implements a text object that escapes characters so it is safe to use in HTML and XML. Characters that have special meanings are replaced so that they display as the actual characters. This mitigates injection attacks, meaning untrusted user input can safely be displayed on a page.
Examples
>>> from markupsafe import Markup, escape
>>> # escape replaces special characters and wraps in Markup
>>> escape("<script>alert(document.cookie);</script>")
Markup('&lt;script&gt;alert(document.cookie);&lt;/script&gt;')
>>> # wrap in Markup to mark text "safe" and prevent escaping
>>> Markup("<strong>Hello</strong>")
Markup('<strong>hello</strong>')
>>> escape(Markup("<strong>Hello</strong>"))
Markup('<strong>hello</strong>')
>>> # Markup is a str subclass
>>> # methods and operators escape their arguments
>>> template = Markup("Hello <em>{name}</em>")
>>> template.format(name='"World"')
Markup('Hello <em>&#34;World&#34;</em>')
Donate
The Pallets organization develops and...
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
MarkupSafe provides a text object that escapes HTML and XML special characters, preventing injection attacks by safely rendering untrusted user input in markup contexts.
Medium install friction due to platform-specific wheels across multiple architectures (x86_64, aarch64, riscv64, Windows variants). Last release 320 days ago with status marked aging, though the repository remains active with recent commits and stable maintenance.
BSD-3-Clause permissive license allows commercial and private use with minimal restrictions, requiring only preservation of copyright and license notices.
Usage
pip install markupsafe==3.0.3
from markupsafe import escape, Markup
print(escape("<script>alert('xss')</script>"))
print(Markup("<strong>Safe</strong>"))
Requires Python 3.9 or later.
Verdict: MarkupSafe is a production-stable, zero-dependency library in the top 100 PyPI packages with no known vulnerabilities. Its aging maintenance status (320 days since last release) is typical for mature, feature-complete security libraries. BSD-3-Clause licensing poses no restrictions for most use cases.
Needs verification
- Whether the 320-day release gap reflects planned stability or reduced active maintenance.
- Performance characteristics compared to alternative HTML escaping approaches in modern Python.
- Coverage of emerging HTML5 or XML namespace edge cases in the current 3.0.3 release.
Similar packages
permissive · top 1,000 on PyPI
itsdangerouspermissive · top 1,000 on PyPI
Jinja2permissive · top 100 on PyPI
uncalled-forpermissive · top 1,000 on PyPI
lxmlpermissive · top 1,000 on PyPI
clickpermissive · top 100 on PyPI
Flaskpermissive · top 1,000 on PyPI
annotated-typespermissive · top 100 on PyPI
Flask-SQLAlchemypermissive · top 1,000 on PyPI
Werkzeugpermissive · top 1,000 on PyPI