Skip to content

HTML Entities Encoder

Escape markup characters, or turn every non-ASCII character into an entity such as é or é.

Processed locally in your browser

Options
0 chars · 0 lines
The result will appear here.

What is HTML Entities Encoder?

HTML entities let you write characters that would otherwise be read as markup (&lt; for <, &amp; for &) or that are hard to type or store (&eacute;, &euro;, &#128512;). Escaping the five special characters is the basic defence against broken pages and injection when text is placed inside HTML.

This encoder has four modes: only the special characters & < > " '; special characters plus named entities for accents and symbols (with numeric fallback where no name exists); or decimal / hexadecimal numeric references for every non-ASCII character. It is a pure string conversion that never touches the DOM.

How does it work?

  1. Paste the text or HTML fragment to escape.
  2. Choose whether to escape only & < > " ' or also convert non-ASCII characters to named, decimal or hex entities.
  3. Copy the result into your template, or press Swap to decode entities back to characters.

Common use cases

  • Showing a code sample such as <div class="x"> inside an HTML page or blog post.
  • Making text safe for an HTML attribute value or email template.
  • Producing ASCII-only HTML for a system that mishandles UTF-8.
  • Converting © ™ € and accented names into entities for legacy CMS fields.

Examples

Try this input in the tool above:

Input
<a href="/search?q=café & thé">Tom & Jerry's café — 5 €</a>
Output
&lt;a href=&quot;/search?q=café &amp; thé&quot;&gt;Tom &amp; Jerry&#39;s café — 5 €&lt;/a&gt;

Privacy

HTML Entities Encoder runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

Entity encoding protects text placed in HTML body or attribute context. It is not a complete defence for JavaScript, CSS or URL contexts, which need their own escaping.

Frequently asked questions

Which characters must always be escaped?

Ampersand (&), less-than (<) and greater-than (>) in text; also double and single quotes inside attribute values. The default mode handles all five.

Why is the apostrophe &#39; and not &apos;?

&apos; is not defined in HTML 4 and older browsers ignore it. &#39; works everywhere, so this tool uses it.

Do I need to encode accented letters?

Not if your page is served as UTF-8, which is the norm. Encoding them is useful for ASCII-only channels or when you cannot control the charset.

More tools in Encoding & Decoding →