HTML-encode Text

Paste text and get HTML entities back instantly.

Options

The result updates as you type. Ctrl + Enter encodes now.

HTML-encoded output

How to HTML-encode text

Paste your text into Your text, or press Load example. The version with HTML entities appears next to it and updates as you type. Copy the result or download it as a .txt file. Everything runs in your browser, so nothing you paste is uploaded.

Examples

InputOutput
<div> &lt;div&gt;
a&b a&amp;b
"hi" &quot;hi&quot;

Limits and edge cases

  • Already-encoded input is encoded again: &amp; becomes &amp;amp;. Encode raw text only once.
  • The apostrophe always becomes numeric &#39;, even in named mode, for maximum browser compatibility.
  • Normal spaces are kept as-is. Only the non-breaking space (U+00A0) becomes &nbsp;.
  • Characters without a named entity, including astral symbols like emoji, become decimal numeric entities such as &#128512;.

Frequently asked questions

How do I HTML-encode text?

Paste your text into the input box and the encoded version with HTML entities appears instantly. Copy it or download it as a .txt file.

What characters get encoded?

The characters & < and > are always escaped. Quotes are escaped when the quote option is on. Every character with a code point above 126 becomes a named entity where one is known, otherwise a numeric entity.

What is the difference between named and numeric entities?

Named entities like &lt; and &copy; are easy to read, while numeric entities like &#60; and &#169; work everywhere. Turn off named entities if you want every special character as a decimal number.

Why does my apostrophe become &#39; instead of a named entity?

The apostrophe has no widely supported named entity in older HTML, so the tool always uses the numeric form &#39; to stay safe in every browser.

Why did my already-encoded text get encoded twice?

The tool escapes every & it sees, so &amp; becomes &amp;amp;. Only encode raw text once, and decode first if the input already contains entities.

Is my text uploaded anywhere?

No. Encoding runs in your browser with JavaScript and nothing is sent to a server. Inputs under 200 KB are kept in your browser's local storage so they are still there when you come back.