HTML Entity Encoder

What Is HTML Entity Encoding?

HTML entity encoding converts special characters into safe representations that browsers display literally instead of interpreting as markup. Characters like < > & and quotes have special meaning in HTML — if included raw in content, they can break your page layout or create XSS (cross-site scripting) security vulnerabilities.

Essential Entities

&amp; → & (ampersand). &lt; → < (less than). &gt; → > (greater than). &quot; → double quote. &apos; → single quote. &nbsp; → non-breaking space. These six entities are the most critical for safe HTML content.

How to Use This HTML Entity Encoder

  1. Paste your text or HTML — Enter the content containing special characters that need encoding.
  2. Select the encoding mode — Named (reserved characters and about 40 common symbols as names), Numeric or Hex (non-ASCII characters as numeric references), or All → Numeric / All → Hex (every character, ASCII included).
  3. View the encoded output — See the HTML entities generated — both named entities (like &amp;) and numeric entities (like &#38;).
  4. Copy and use — Paste the encoded text into your HTML where special characters need to be displayed literally.

Worked example: encoder output checked in a browser

Until October 12, 2026 the Named mode turned every space into &nbsp;, the Numeric and Hex modes split emoji into two broken references and the decoder knew 40 of HTML's 2,231 named references. All three are fixed. We then ran the tool's own functions in Chromium: decoding matched Python's html.unescape (the WHATWG list) on 12 of 12 test strings, and 5 strings × 5 modes all decoded back to the original text.

ModeInputOutputResult
Named (default)5 < 6 & café 😀5 &lt; 6 &amp; café 😀spaces stay spaces; only characters with a name are replaced
Numeric / Hex😀&#128512; / &#x1F600;one reference per character, renders as 😀
Numeric👨‍👩‍👧&#128104;&#8205;&#128105;&#8205;&#128103;the joined emoji keeps its zero-width joiners
Decode&#128512;😀correct above U+FFFF
Decode&rsquo; &hearts; &AMP; &not’ ♥ & ¬all named references, including legacy forms without a semicolon
Decode&nbsp;U+00A0a real non-breaking space
Decode</textarea><script>…the same text backdecoded as text; nothing runs

Frequently Asked Questions

What are HTML entities?
Special codes representing characters with HTML meaning (< > &) or special symbols (© ™ €). They start with & and end with ; — for example, &amp; represents the ampersand.
Why encode HTML entities?
Raw < or > characters are interpreted as tags. Encoding them as &lt; and &gt; displays them literally, preventing rendering errors and XSS security vulnerabilities.
What is the difference between encoding and escaping?
In HTML context, they mean the same thing — converting special characters to entity equivalents. Escaping is more common in programming; encoding in web standards.
Why do I need to encode HTML entities?+
HTML uses certain characters as part of its syntax — < and > define tags, & starts entities, and quotes delimit attribute values. If you want these characters displayed as text, you must encode them. Without encoding, the browser interprets them as HTML markup, which can break your layout or create security vulnerabilities.
What is the difference between named and numeric HTML entities?+
Named entities use human-readable names (&amp;, &lt;, &copy;) and are easier to remember. Numeric entities use Unicode code points (&#38;, &#60;, &#169;) and can represent any Unicode character. Named entities only exist for a subset of characters, while numeric entities cover the entire Unicode range.

📖 Learn More

Related Article How to Encode HTML Entities for the Web →

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service