--- id: markupsafe version: "3.0.3" license: BSD-3-Clause license_treatment: permissive maintenance: aging --- # MarkupSafe — Safely add untrusted strings to HTML/XML markup. License: permissive · Maintenance: aging · Popularity: top 100 on PyPI ## Install pip install markupsafe uv add markupsafe poetry add markupsafe ## Description
# 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 ```pycon >>> from markupsafe import Markup, escape >>> # escape replaces special characters and wraps in Markup >>> escape("") Markup('<script>alert(document.cookie);</script>') >>> # wrap in Markup to mark text "safe" and prevent escaping >>> Markup("Hello") Markup('hello') >>> escape(Markup("Hello")) Markup('hello') >>> # Markup is a str subclass >>> # methods and operators escape their arguments >>> template = Markup("Hello {name}") >>> template.format(name='"World"') Markup('Hello "World"') ``` ## Donate The Pallets organization develops and... ## AI interpretation — verify before relying MarkupSafe provides a text object that escapes HTML and XML special characters, preventing injection attacks by safely rendering untrusted user input in markup contexts. 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. [View on SkillFed](https://skillfed.io/packages/markupsafe) · [View on PyPI](https://pypi.org/project/markupsafe/)