HTML Entity Encoder

Turn text into safe HTML. In the default mode the five characters that have special meaning in HTML (&, <, >, double and single quotes) are replaced with entities so the text can be placed inside a page without being treated as markup. You can also convert accented letters, symbols and other non-ASCII characters to named, decimal or hexadecimal entities, and look up any of more than 250 common named entities in the table below.

Encoding & Security Runs in your browser

Encode Text as HTML Entities

How to Use the HTML Entity Encoder

  1. Paste or type your text in the box.
  2. Choose what to encode: only the special characters, or all non-ASCII characters too.
  3. Pick decimal or hexadecimal if numeric entities are needed.
  4. Copy the encoded text. Use the search box to look up a specific entity in the reference table.

About This Tool

Web developers and content editors who paste code samples or special characters into HTML, email template authors, and anyone who needs to look up an entity name for a symbol.

Input: Plain text  ·  Output: HTML-encoded text.

Features and Limitations

Features

  • Escapes & < > " ' so text is safe as HTML text and in attribute values.
  • Converts non-ASCII characters to named entities where an HTML name exists, otherwise to numeric references.
  • Decimal or hexadecimal numeric output, and emoji and other characters beyond the basic plane are handled correctly.
  • Searchable table of the 252 classic HTML named entities plus &apos;.
  • All processing is local.

Limitations

  • Encoding is not a security measure by itself. Which characters need escaping depends on where the text goes (HTML text, attribute, JavaScript, URL), and this tool targets HTML text and quoted attributes.
  • Named entities come from the classic HTML 4 set; characters outside it become numeric references even in “named” mode.
  • Modern pages in UTF-8 do not need non-ASCII characters encoded; the option exists for legacy systems and for pure ASCII output.
  • The single quote is written as &#39; because &apos; is not valid in HTML 4 and some old email clients.
  • Results are computed in your browser; nothing you enter is sent to a server.

Example

With the default text, <p class="intro">Café — “naïve” price: 5 € & more</p>, special-characters mode gives &lt;p class=&quot;intro&quot;&gt;Café — “naïve” price: 5 € &amp; more&lt;/p&gt;. In named mode, é, — and € also become &eacute;, &mdash; and &euro;.

Frequently Asked Questions

Which characters must be escaped in HTML?

Always & and <. Also > for readability and the quote character that delimits an attribute value (" or '). The tool encodes all five so the output is safe in both text and attributes.

What is the difference between named and numeric entities?

A named entity such as &eacute; is easier to read, while a numeric one such as &#233; (decimal) or &#xE9; (hex) exists for every Unicode character. All three render the same character.

Do I need to encode accented letters or emoji?

Not if your page is served as UTF-8 and declares it, which is the norm today. Encoding them is only useful for ASCII-only systems.

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

&apos; is valid in XML and HTML5 but not in HTML 4, and some older clients do not understand it. The numeric form works everywhere.

Is the tool safe for untrusted text?

Yes for conversion: your text is processed as plain text and never inserted as live HTML.

Related Tools

More like this: all Encoding & Security tools, all Developer & Web tools or the TinySandy home page.