htmlEasy Examples

HTML entity escaping and unescaping

Getting started with html

Basic import and usage of the html module.

python
import html

# Escape HTML
text = '<script>alert("XSS")</script>'
safe = html.escape(text)
print(f"Escaped: {safe}")

# Unescape
print(f"Unescaped: {html.unescape(safe)}")

The html module is part of Python's standard library. HTML entity escaping and unescaping.

Common html operations

Frequently used functions from the html module.

python
# More html examples
import html

print(f"html module loaded successfully")
print(f"Location: {html.__name__}")
print(f"Has {len(dir(html))} attributes")

These are the most commonly used features of the html module.

Want to try these examples interactively?

Open Easy Playground