How to use the HTML Encoder / Decoder
- Paste your text or HTML
- Click Encode or Decode
- Copy the result
Encode and decode HTML entities
Paste text and click Encode HTML to escape the five special characters โ & โ &, < โ <, > โ >, " โ " and ' โ ' โ or Decode HTML to turn entities back into plain text. Tick โAlso encode non-ASCII charactersโ to write ยฉ or emoji as numeric entities such as ©.
What are HTML entities?
They are codes that display a character the browser would otherwise treat as markup, or one that is hard to type. Some common ones:
- Ampersand
&ยท less than<ยท greater than> - Single quote
'(or') ยท double quote" - Non-breaking space
ยท ยฉ©ยท โข™ยท โ→
Why escaping matters
If text typed by users is shown on a page without escaping, someone can inject scripts โ a cross-site scripting (XSS) attack. Always escape text before inserting it into HTML; the five characters above are the ones that matter. This page is handy for checking output and for preparing snippets, such as showing code in a blog post.
In code
- JavaScript โ set
element.textContentinstead ofinnerHTML, or replace the five characters. - PHP โ
htmlspecialchars($s, ENT_QUOTES); decode withhtml_entity_decode(). - C# โ
WebUtility.HtmlEncode()andHtmlDecode().