Format Code Now
/
Encode & decodeText to HTML Entities Next: UTF-8 Converter ›

Text to HTML Entities Converter

ED-63

Paste text and turn special characters into HTML entities. Choose just the markup characters, all non-ASCII characters, or every character as a number.

Runs in your browser. Nothing is uploaded.

Plain text

Result

How to use it

  1. Paste your plain text into the input box.
  2. Under Encode, choose only & < > " and ', those plus non-ASCII characters, or every character as a number.
  3. For non-ASCII characters, pick names, decimal or hex.
  4. Click Text to entities and copy the result into your HTML.

Three levels of encoding

The first level converts only the five characters that matter in markup: & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot; and the apostrophe becomes &#39;. The second level also converts every character above U+007F, using a name where the built-in table has one, so é becomes &eacute;, and a number otherwise. The third writes every character, letters included, as &#NN; or &#xHH;.

When to use which

Use the first level for text that will be placed inside HTML, so it displays literally instead of being read as markup. Use the second when the file or system you send it to cannot carry non-ASCII characters safely. The third produces unreadable source that still renders the same, so it only suits special cases. It does not hide an address from a determined scraper, since any parser decodes it.

Limits

Entities make text safe to display, but they are not a complete defense against injection in every context. Text placed inside a script, a style block or an unquoted attribute needs different handling. Unpaired surrogates in the input cannot be written as entities and are reported. Decoding the other way is available in the second button.

Error messages and what to do

MessageWhat it meansFix
Unpaired surrogateThe text has half of an emoji, which cannot be written as an entity.Remove or replace the broken character.
The input has an unpaired surrogateSame cause, found while writing every character as a number.Remove or replace the broken character.

Questions people ask

How do I convert text to HTML entities?

Paste the text, choose how much to encode and click Text to entities. By default the markup characters and all non-ASCII characters are encoded, with names such as &eacute; where a name exists.

Which characters must be escaped in HTML?

In text, & and < always, and > by convention. In attribute values the quote that wraps the value also needs escaping. This tool handles all five: & < > " and '.

What is the difference between &eacute; and &#233;?

They produce the same character, é. One uses a name and the other a decimal code point. A number always works, while a name only works if the browser knows it. Pick Decimal or Hex to always use numbers.

Why encode every character as a number?

Mostly for special cases where text must pass through a system that treats letters specially. It renders identically in a browser. It does not protect an email address from scrapers, because decoding numeric references is trivial.

Should I use entities instead of UTF-8?

If your pages are served as UTF-8, you can write é directly and only escape the markup characters. Entities for non-ASCII text are mainly useful when a file may be saved or sent in a different encoding.

How do I turn entities back into text?

Click Entities to text. It decodes decimal and hex references and the names in its built-in table. Names outside the table are left as typed, so check the output if the text came from an unusual source.

About this tool

The first two options always convert the five characters that matter in markup: & < > " and '. The apostrophe becomes &#39;. The second option also converts every character above U+007F, using a name where the built-in table has one (é becomes &eacute;) and a number otherwise. The third option writes every character, letters included, as a decimal or hex number, which makes text unreadable in the source but renders the same; it does not hide an address from a determined scraper. Entities make text safe to show in HTML, but they are not a complete defense against injection in every context, such as inside a script or an attribute with no quotes.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.