util·tools

HTML Entity Encoder & Decoder

Some characters — like the less-than sign, greater-than sign and ampersand — have special meaning in HTML, so to show them as plain text you replace them with safe codes called "entities". This tool encodes those characters into entities and decodes entities back into normal text. It runs in your browser.

Related tools

About this html entity encoder & decoder

In HTML, a few characters are reserved: < and > mark tags and & begins a code, so to display them literally you swap them for HTML entities such as &lt;, &gt; and &amp;. Encoding does this for you, which is important whenever you put user text inside a web page, because it stops stray characters from breaking the layout or being read as code. Decoding does the reverse, turning entities — including numbered ones like &#39; and &#x41; — back into the characters they stand for. Both directions run entirely in your browser.

Frequently asked questions

What is an HTML entity?
It is a short code that stands for a character, like &amp;lt; for the less-than sign. Browsers display the character but treat the code as plain text.
Which characters get encoded?
The main reserved ones: < becomes &amp;lt;, > becomes &amp;gt;, &amp; becomes &amp;amp;, and the quote marks become &amp;quot; and &amp;#39;.
Can it decode number codes?
Yes. It handles named entities as well as numeric ones in both decimal (&amp;#39;) and hexadecimal (&amp;#x41;) form.

How HTML Entities Work Behind the Scenes

HTML entities rely on a specific syntax recognized by browser parsers to differentiate literal text content from markup instructions. Every named entity starts with an ampersand and ends with a semicolon, with a short mnemonic keyword in between, such as lt for less than. Numeric entities instead use a hash symbol followed by either the decimal code point or an x followed by the hexadecimal code point. When the browser rendering engine encounters these sequences in the HTML source tree, it resolves them against the character set and paints the corresponding glyph on the screen.

This encoding convention originates from the early days of the World Wide Web when documents were written in ASCII, which lacked many international symbols and reserved characters. The standard was established to prevent parser ambiguity, ensuring that structural delimiters like angle brackets could be displayed as plain text instead of triggering tag creation. As specifications evolved to support Unicode, the entity system expanded to encompass thousands of symbols, accents, and emoji, allowing developers to safely reference virtually any character from the Universal Character Set inside standard text files.

The most frequent mistake developers make is encoding text multiple times or applying entity encoding to entire HTML documents instead of specific text nodes. Double encoding transforms an ampersand into an entity, which then gets encoded again during a subsequent processing pass, resulting in broken strings like ampersand amp semicolon appearing visibly on the page. Another common pitfall is forgetting that attribute values inside HTML tags also require proper entity escaping to prevent attribute injection vulnerabilities and premature closure of quotes.