Skip to main contentSkip to secondary navigation
HomedevtoolsHTML Entities

HTML Entity Encoder/Decoder — Encode & Decode HTML Entities

Encode and decode HTML entities instantly. Convert special characters to HTML entities and back between named, decimal, and hex entity formats.

✓ Formula verified: January 2026
💻

HTML Entities

Results update instantly as you type

Enter Values

The Formula

Encode: & &amp; | < &lt; | > &gt; | " &quot; | ' &#39; Decode: Named (&amp; → &), Decimal (&#38; → &), Hex (&#x26; → &)

HTML entity encoding converts special characters (like <, >, &, ", ') into their corresponding HTML entity references so they display correctly in web pages without being interpreted as markup. Decoding reverses this process, converting entity references back to their original characters. Three formats are supported: named entities (&), decimal numeric entities (&#38;), and hexadecimal entities (&#x26;).

Variable Definitions

&amp;

Named Entity

A mnemonic name for a character preceded by an ampersand and followed by a semicolon. Examples: &amp; for &, &lt; for <, &gt; for >.

&#38;

Decimal Numeric Entity

A character reference using its Unicode code point in decimal format. The format is &# followed by the decimal number and a semicolon.

&#x26;

Hexadecimal Numeric Entity

A character reference using its Unicode code point in hexadecimal format. The format is &#x followed by the hex number and a semicolon.

HTML Context

HTML Parsing Context

The HTML spec defines where entity parsing applies. Entities are resolved in HTML content but not inside <script> or <style> blocks in modern browsers, though they should still be encoded for safety.

How to Use This Calculator

  1. 1

    Select the mode: "Encode to Entities" to convert special characters, or "Decode to Text" to convert entities back.

  2. 2

    Enter or paste your input text in the text area — either raw text with special characters or text containing HTML entities.

  3. 3

    View the encoded or decoded output result, along with character counts for both input and output.

Quick Reference

FromTo
& → &amp;amp;Ampersand — must always be encoded in HTML to avoid ambiguous entity parsing
< → &amp;lt;Less-than — must be encoded to prevent being interpreted as an HTML tag opening
> → &amp;gt;Greater-than — encoded for symmetry with less-than, though not strictly required
" → &amp;quot;Double quote — must be encoded inside attribute values delimited by double quotes

Common Applications

  • Displaying code snippets on blogs and documentation sites without breaking the page layout
  • Sanitizing user-generated content before rendering it in web applications to prevent XSS attacks
  • Encoding special characters in HTML email templates to ensure consistent rendering across email clients
  • Processing scraped web content that contains encoded characters back into readable text
  • Preparing data for XML documents where certain characters have special meaning and must be escaped

HTML entity encoding converts special characters to entity references; decoding reverses the process

Understanding the Concept

HTML entity encoding is a fundamental security and display technique in web development. When a web browser encounters HTML markup, it parses angle brackets (< >) as tag delimiters, ampersands (&) as entity starters, and quotes as attribute delimiters. If user-generated content or dynamic data containing these characters is inserted directly into HTML without encoding, it can break page rendering or introduce cross-site scripting (XSS) vulnerabilities. The encoding process converts these five essential characters into their corresponding entity references: & becomes &, < becomes <, > becomes >, " becomes ", and ' becomes ' (or &apos; in XHTML). The decoding process is more complex because there are three formats in widespread use. Named entities like &, <, and &copy; are defined by the HTML specification and provide human-readable mnemonics. Decimal numeric entities like &#38; reference characters by their Unicode code point in base 10. Hexadecimal numeric entities like &#x26; use base 16, which can be more convenient when referring to code points from Unicode charts. The HTML5 specification defines 2231 named character entities covering a wide range of symbols, punctuation, and international characters. When decoding, the entity parser must handle all three formats, plus edge cases like missing semicolons (which are tolerated in certain contexts per the HTML spec), invalid code points, and entities that decode to non-printable characters. This tool handles the full range of named entities and properly processes both decimal and hexadecimal numeric entities for comprehensive encoding and decoding support.

Frequently Asked Questions

Related Calculators

Reviews

No reviews yet. Be the first to share your experience with HTML Entity Encoder/Decoder — Encode & Decode HTML Entities.

Write a Review

Your Rating *

0/1000

0/50

Related Calculators

Medical Disclaimer: The health and fitness calculators on this site are for informational and educational purposes only. They are not a substitute for professional medical advice, diagnosis, or treatment. Always consult a qualified healthcare provider with any questions about your health.

Financial Disclaimer: The finance calculators on this site are for informational purposes only and do not constitute financial advice. Results are estimates based on the inputs provided and may vary. Consult a qualified financial advisor before making investment or financial decisions.

© 2026 TheCalcUniverse. All results are for informational purposes only.

Fast, free, and privacy-first.