Skip to content

HTML Entity Encode and Decode

Convert special characters to HTML entities and decode HTML entities back to readable text.

HTML Entity Encode and Decode tool

Loading...

Example

Input: <a href="x">Tom & Jerry</a>

Result: &lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&lt;/a&gt;

The characters that have special meaning in HTML are replaced by entities: < becomes &lt;, > becomes &gt;, & becomes &amp; and " becomes &quot;.

Characters the Encoder Escapes

CharacterEncoded asWhy it matters
&&amp;Starts every entity
<&lt;Opens a tag
>&gt;Closes a tag
"&quot;Ends a double-quoted attribute
'&#39;Ends a single-quoted attribute
© é emojiunchangedShown directly on UTF-8 pages
  1. To encode, paste your text or HTML containing special characters into the HTML panel.
  2. To decode, paste text containing HTML entities (named, decimal, or hexadecimal) into the Encoded panel instead.
  3. The other panel updates instantly - encoding escapes &, <, >, double quotes, and apostrophes.
  4. Review the converted output and use the swap button if you want to run the result through again.
  5. Click the copy button to copy the encoded or decoded text for use in your HTML document.

HTML Entities: Escaping Special Characters

HTML entity encoding replaces characters that HTML treats as markup with safe codes. This tool turns & into &amp;, < into &lt;, > into &gt;, " into &quot; and ' into &#39;. It also decodes entities back into the characters they stand for.

Browsers read < as the start of a tag. To show the text <script> on a page, for example in a code sample or a user comment, you have to write &lt;script&gt;. The same escaping is a key defense against cross-site scripting (XSS), where an attacker slips HTML into a page through a form or URL. Escaping these five characters in page text and quoted attribute values stops that input from turning into markup. The encoder changes only those five characters. Accented letters, symbols like © and emoji are left alone, since a page served as UTF-8 displays them directly. That keeps the output short and easy to read.

The decoder understands named entities such as &copy; and &nbsp;, decimal codes such as &#169; and hex codes such as &#xA9;, all three of which give ©. It works in a single pass, so &amp;lt; becomes &lt; and not <. That helps when you look at text that was escaped twice by mistake. For links, use URL Encode and Decode instead, since URLs use %XX codes, not entities.

Sources

Frequently Asked Questions

A named entity uses a word, such as &copy; for © or &amp; for &. A numeric entity uses the character's Unicode number, in decimal (&#169;) or hex (&#xA9;). Numeric entities work for every character, while names exist only for a set list. This decoder reads all three forms.
Modern pages are served as UTF-8, which can show any character directly, so turning them into entities only makes the HTML longer and harder to read. Only characters that HTML itself treats as markup need escaping. If you must deliver pure ASCII, write numeric entities such as &#233; for those characters yourself.
It stops input from becoming markup in page text and quoted attributes, which covers the most common case. It is not enough inside JavaScript code, CSS, or URLs such as href="javascript:...". Each of those needs its own escaping or validation. Use your framework's built-in escaping and a Content Security Policy as extra layers.
The text was escaped twice, so the browser decodes one layer and shows the entity instead of the character. It usually happens when content that is already escaped passes through a second escaping step, such as a template. Paste it into the decoder once to see the intended text, then remove the extra step.
It is a non-breaking space. It looks like a normal space but stops the browser from breaking a line at that point, which keeps pairs like 10&nbsp;km together. The decoder turns it into the real non-breaking space character (U+00A0). That character is not the same as an ordinary space, so code that compares text may treat the two differently.

Related Tools

URL Encode and Decode

Encode special characters for URLs or decode percent-encoded strings back to readable text.

Developer Tools

Base64 Encode and Decode

Encode text to Base64 and decode Base64 strings back to readable text, with full UTF-8 support.

Developer Tools

HTML Minifier

Minify HTML by removing comments and collapsing whitespace between tags and inside tags to reduce document size.

Developer Tools

JSON Formatter and Validator

Format, validate, beautify, and minify JSON data with a collapsible tree view and line-and-column error detection.

Developer Tools

CSS Minifier

Minify CSS by removing whitespace, comments, and redundant code to reduce file size.

Developer Tools

Regex Tester

Test regular expressions with real-time match highlighting, group capture display, and a pattern library.

Developer Tools