Encoding

HTML Entity Encode/Decode

Escape text to HTML entities or decode named and numeric entities back to plain text. Runs entirely in your browser; nothing you type is ever sent anywhere.

Raw Text / HTML
Entity-Encoded
Encoded output will appear here.

Quick Learn

HTML entity encoding replaces characters that have special meaning in HTML markup — &, <, >, ", ' — with a named or numeric escape sequence, so they render as literal text instead of being parsed as a tag, attribute boundary, or the start of another entity. &amp; renders as &, &lt; renders as <, and so on. Without this, user-submitted text containing < or & could break page layout or, worse, be interpreted as actual markup.

Entities come in two forms: named (&amp;, &copy;, &hellip;) and numeric (&#38; or &#x26; for the same &). Named entities are easier to read in source; numeric entities work for any Unicode character, even ones without a memorable name, using either decimal (&#NNNN;) or hexadecimal (&#xHHHH;) code points. This tool's decoder accepts both forms interchangeably, since real-world HTML mixes them freely — copy-pasted content, CMS exports, and RSS feeds often use whichever form the original tool happened to emit.

Best Practices

  • •Encoding user input before rendering it as HTML is a basic XSS defense — but it's not a substitute for a proper templating engine or sanitizer that handles attribute contexts, URLs, and JavaScript contexts differently.
  • •Only the five characters & < > " ' are strictly required for safe HTML embedding — encoding everything else (accented letters, emoji) as numeric entities is unnecessary today, since UTF-8 is universally supported.
  • •Encode & first, before any other character — encoding < to &lt; and then encoding the & in that output would double-encode it into &amp;lt;, corrupting the entity.
  • •When decoding content from an unknown source, treat the output as untrusted text, not as safe-to-render HTML — decoding entities does not itself make the content safe.

More Encoding Tools

See all Encoding tools

Frequently Asked Questions

Is my text uploaded anywhere?

No. Encoding and decoding both run entirely in your browser with plain string replacement — nothing you paste is sent to a server.

Which characters get encoded?

Encode mode escapes the five characters that are structurally significant in HTML: & (amp), < (lt), > (gt), " (quot), and ' (apos). Other Unicode characters are left as-is, since modern browsers render UTF-8 text correctly without needing numeric entities.

Does decoding support numeric entities like &#39; or &#x27;?

Yes — decode mode handles named entities (&amp;, &copy;, &hellip;, and other common ones), decimal numeric entities (&#39;), and hexadecimal numeric entities (&#x27;) all in the same pass.

Is entity-encoding enough to prevent XSS?

It's one layer, not a complete defense. Encoding text content is generally safe, but injecting user input into an HTML attribute, a <script> block, or a URL requires different, context-specific escaping — a dedicated sanitizer library handles those cases correctly.

Why didn't an unrecognized entity get decoded?

Only a curated set of common named entities is recognized by name; an obscure or non-standard named entity is left untouched rather than guessed at. Numeric entities (&#NNNN; or &#xHHHH;) always decode, since they specify an exact Unicode code point.

Want the engineering deep-dives behind tools like this one?