usefmtly

HTML Entity Encoder / Decoder

HTML Entity Encoder / Decoder — Free online HTML entity encoder and decoder. Escape HTML special characters to prevent XSS and rendering issues, or decode HTML entities back to readable text. Supports named, decimal, and hex entities.

0Input length
0Output length
0Encoded
Ess.Mode
Plain text / HTML
Escaped HTML

How to encode and decode HTML entities

  1. Choose Encode or Decode. Encode escapes characters for safe HTML insertion; Decode converts entities back to plain text.
  2. Choose Essential or All chars mode (encode only). Essential encodes the five critical characters — & < > " '. All chars additionally encodes accented letters, symbols, and emoji as numeric entities.
  3. Paste your text or HTML. The result appears instantly.
  4. Use Swap to round-trip the output back through the tool.

Essential HTML entities reference

CharacterEntityNumericWhy it matters
&&amp;&#38;Starts all entities — must be encoded first
<&lt;&#60;Opens HTML tags — raw < breaks markup
>&gt;&#62;Closes HTML tags
"&quot;&#34;Delimits attribute values in double quotes
'&#39;&#39;Delimits attribute values in single quotes
©&copy;&#169;Copyright — commonly needed
&mdash;&#8212;Em dash — often pasted as a raw character
&hellip;&#8230;Ellipsis — three dots as one glyph

When to use each mode

Essential mode is correct for the vast majority of use cases. Encoding the five critical characters is sufficient to prevent HTML injection, XSS, and layout breakage when inserting user-generated content into HTML.

All chars mode is useful for generating HTML email that must render correctly in old email clients that do not support UTF-8, or for embedding text in HTML documents with a non-UTF-8 charset declaration. Modern browsers handle UTF-8 natively so raw Unicode in HTML is fine.

Related tools: URL Encoder for percent-encoding URLs, Base64 Encoder for binary-to-text encoding, or the JSON Formatter to validate and format JSON.

Frequently Asked Questions

What are HTML entities?

HTML entities are special codes used to represent characters that have meaning in HTML (like < > & ") or characters not easily typed on a keyboard. They start with & and end with ; — for example &lt; represents < and &amp; represents &.

Why do I need to encode HTML characters?

If you insert raw characters like < or & into HTML without encoding them, the browser may interpret them as HTML tags or entity starts, breaking your layout or creating security vulnerabilities (XSS). Encoding them as &lt; and &amp; makes them display correctly as text.

What is the difference between Essential and All modes?

Essential mode encodes only the five critical characters: & < > " '. This is sufficient for safely inserting text into HTML. All mode additionally encodes any character outside basic ASCII (accented letters, symbols, emoji) as numeric entities — useful for maximum compatibility with older systems.

What types of entities can this tool decode?

The decoder handles named entities (&amp; &lt; &copy; etc.), decimal numeric entities (&#65;), and hexadecimal numeric entities (&#x41;). Unknown named entities are left unchanged.

Does this prevent XSS attacks?

Encoding user input with HTML entities before inserting it into HTML prevents most reflected XSS attacks. However, context matters — encoding for HTML attributes, JavaScript strings, and CSS requires different escaping rules. This tool handles HTML text content and attribute values.

Related Tools