skillfed

MarkupSafe

Safely add untrusted strings to HTML/XML markup.

markupsafe Permissive license BSD-3-Clause AGING 694 v3.0.3 released

Install

markupsafe on PyPI

pip

pip install markupsafe

uv

uv add markupsafe

poetry

poetry add markupsafe

Package 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonTopic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Text Processing :: Markup :: HTMLTyping :: Typed

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

&gt;&gt;&gt; from markupsafe import Markup, escape

&gt;&gt;&gt; # escape replaces special characters and wraps in Markup
&gt;&gt;&gt; escape("&lt;script&gt;alert(document.cookie);&lt;/script&gt;")
Markup('&amp;lt;script&amp;gt;alert(document.cookie);&amp;lt;/script&amp;gt;')

&gt;&gt;&gt; # wrap in Markup to mark text "safe" and prevent escaping
&gt;&gt;&gt; Markup("&lt;strong&gt;Hello&lt;/strong&gt;")
Markup('&lt;strong&gt;hello&lt;/strong&gt;')

&gt;&gt;&gt; escape(Markup("&lt;strong&gt;Hello&lt;/strong&gt;"))
Markup('&lt;strong&gt;hello&lt;/strong&gt;')

&gt;&gt;&gt; # Markup is a str subclass
&gt;&gt;&gt; # methods and operators escape their arguments
&gt;&gt;&gt; template = Markup("Hello &lt;em&gt;{name}&lt;/em&gt;")
&gt;&gt;&gt; template.format(name='"World"')
Markup('Hello &lt;em&gt;&amp;#34;World&amp;#34;&lt;/em&gt;')

Donate

The Pallets organization develops and...

Read as markdown · JSON record · Source repository · Docs

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.
html escaping libraryxss preventionsafe markup handlinghtml injection protectionuntrusted string sanitizationxml character escapingtemplate safe strings

Similar packages