Free & private
Text & web

HTML entity encode and decode

Escape the characters that have meaning in HTML so your text shows up as written instead of being parsed as markup — and decode entities back to plain characters.

Reversible100% FreeNo upload
HTML entities
Text & web · reversible · UTF-8
try
Input0 chars · 0 bytes
Output0 chars · 0 bytes
UTF-8 · ready⌘⏎ copy⌘⇧S swap● local

Why HTML entities exist

A handful of characters are special in HTML: < and > start and end tags, & begins an entity, and quotes delimit attribute values. If you want to display those characters rather than have the browser act on them, you replace each with an entity — a name or number between & and ;. So <b> written as &lt;b&gt; appears on the page as literal text instead of turning the following words bold.

How to use this tool

  1. Paste your text on the left to encode the five special characters, or paste entity-laden HTML to decode it.
  2. Tick Encode every character to turn all non-ASCII characters into numeric entities too — handy when a system only accepts 7-bit ASCII.

Decoding understands named entities (&copy;), decimal references (&#169;) and hexadecimal ones (&#xA9;) alike.

Security: escaping untrusted text

Entity-encoding is the core defence against cross-site scripting. Any text that comes from a user and gets placed into a page must be escaped first, so a string like <script> is rendered as characters, not executed as code. This tool is useful for inspecting and testing that escaping, though in production the encoding should happen automatically in your template layer.

Named vs numeric entities

Some characters have friendly names — &nbsp;, &copy;, &mdash; — while every character also has a numeric form. Numeric entities always work because they do not depend on the name being recognised, which is why the "encode every character" option emits numbers.

Examples

Input<a href="x">Tom & Jerry</a>
Output&lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&lt;/a&gt;

Frequently asked questions

Which characters need HTML encoding?
At minimum the five with special meaning: & < > " and '. Encoding those is enough to keep text from being parsed as markup. Non-ASCII characters are optional and only needed for ASCII-only output.
Does HTML encoding stop XSS?
Correctly escaping untrusted text before it enters a page is the main defence against cross-site scripting. The right place to do it is automatically in your template engine; this tool helps you inspect and test the result.
What is the difference between named and numeric entities?
Named entities like © are readable; numeric entities like © or © reference the character by code point and always work. Both decode to the same character.
Is my input sent anywhere?
No. Everything runs in your browser.

Related tools

Every tool on encoder.website converts your text and hands the result straight back — it is never stored. Pick another tool from the sidebar any time.