How HTML Entities Prevent Broken Markup
Learn how HTML entities let developers show reserved characters safely inside markup, templates and documentation.
By Lumarc Studio · Updated 2026-07-29
HTML uses characters such as <, >, & and quotes as syntax. When those characters are part of the text you want to display, they can break markup or be interpreted as tags and attributes.
HTML entities represent those characters safely:
<button>Save</button>
renders as visible text instead of becoming an actual button element.
Common Entities
< means <
> means >
& means &
" means "
The HTML Entity Encoder converts reserved characters into entities. The HTML Entity Decoder converts entity-heavy text back into readable characters.
Entities Are Not Full Sanitization
Escaping text is a useful safety step when you want to display untrusted text inside HTML. But a complete sanitizer has to understand full HTML structure, allowed tags, allowed attributes and URL safety rules.
Use entity encoding for plain text display and documentation examples. Use a proper sanitizer when accepting rich HTML from users.
Documentation Use Case
Entities are especially useful when writing tutorials:
<script>alert("example")</script>
The snippet remains readable without executing as markup.