HTML Entity Converter

Encode text into HTML character references or decode references back to characters.

Technology and NetUpdated 2026-11-202 min read
HTML Entity Converter
Up to 4,096 characters. Encoding handles ASCII and non ASCII characters.
Converted text
...
Replacements made...
Direction used...

What it does

HTML gives certain characters a special job. The less than sign opens a tag, the ampersand starts a character reference, and quotes delimit attribute values. To show those characters as ordinary text, you replace them with character references, also called entities.

The HTML Standard maintained by the Web Hypertext Application Technology Working Group lists named character references and the code points they represent. MDN explains the same idea in plain language and describes decimal and hexadecimal numeric references as alternatives to names.

Encoding here replaces the five reserved ASCII characters with standard references and converts every character above ASCII into a decimal numeric reference. Decoding reads named references from a small table and also understands decimal and hexadecimal forms, then puts the original characters back.

This tool works on text you paste and shows how many replacements it made. It does not parse HTML or change tags, so it is meant for short snippets and for learning how references work, not for sanitising a whole document.

Character encoding is about displaying text correctly. It is not a security measure. Preventing script injection needs proper output escaping in the context where the text is used.

How to use

  1. Choose Encode to turn reserved characters into references, or Decode to reverse the process.
  2. Paste or type the text into the input box. The page opens with an encoded example.
  3. Read the converted text in the main result area.
  4. Check the replacements count to see how many characters changed.
  5. Switch direction and paste the result back to confirm the round trip.
  6. Use the table below when you need a specific named reference by hand.

Formula

Encode: reserved character maps to its named or numeric reference. Decode: reference &name; or &#number; maps back to its character.
&
The ampersand that begins every character reference.
;
The semicolon that ends a named or numeric reference.
©
A decimal numeric reference for the copyright sign.
—
A hexadecimal numeric reference form accepted by the decoder.

The encoder uses & for an ampersand, < for less than, > for greater than, " for a double quote and ' for a single quote. Characters above code 126 become decimal numeric references. The decoder supports a short list of common names plus any decimal or hexadecimal code point.

Worked example

Example: encoding a short sentence

Input text: A < B & "C" ©

  1. The letter A needs no change, and neither does the space.
  2. The less than sign becomes &lt;, the first replacement.
  3. The ampersand becomes &amp;, the second replacement.
  4. The double quotes around C each become &quot;, replacements three and four.
  5. The copyright sign has code 169, so it becomes &#169;, the fifth replacement.
  6. The result is A &lt; B &amp; &quot;C&quot; &#169;, shown with 5 replacements.
  7. Switching to Decode and pasting that string returns the original text.

Reference table

Common character references
CharacterNamed referenceNumeric reference
&&amp;&#38;
<&lt;&#60;
>&gt;&#62;
"&quot;&#34;
'&#39;&#39;
©&#169;&#169;
non breaking space&nbsp;&#160;

Limits

  • The named reference table covers common names only, not the full HTML Standard list.
  • The tool does not parse tags or attributes, so it is not a document sanitiser.
  • Input is limited to 4,096 characters to keep the browser responsive.
  • Hexadecimal decoding needs the lowercase or uppercase x prefix, as in &#x41;.

Common mistakes

  • Forgetting the trailing semicolon on a named reference, which some parsers still accept but the standard discourages.
  • Encoding an ampersand twice, turning &amp; into &amp;amp;.
  • Expecting the encoder to know every named reference in the HTML Standard.
  • Confusing character encoding with protection against script injection.
  • Decoding a string that contains raw tags and assuming the result is safe to insert into a page.

Try it yourself

Quick checks. Answers sit tucked under each question.

Encode the string A < B & "C" ©. How many replacements?

5. The result is A &lt; B &amp; &quot;C&quot; &#169;.

What does &#169; decode to?

The copyright sign ©, decimal code point 169.

What is the named reference for a non breaking space?

&nbsp;. The numeric equivalent is &#160;.

Questions

What is a character reference?

An escape sequence that represents a character in HTML, either by name such as &lt; or by number such as &#60;.

Why must < be encoded?

Because the HTML parser reads it as the start of a tag. Encoding it makes it display as a literal character.

What is the difference between named and numeric references?

Named references use a readable name, while numeric references give the Unicode code point in decimal or hexadecimal.

Does the decoder handle hexadecimal references?

Yes. A form such as &#x41; is read as code point 65 and returns the letter A.

Is this a security tool?

No. It converts text for display. Security needs context aware escaping in the code that renders the text.

Where can I see the full list of names?

The HTML Standard section on named character references, linked below, lists every supported name and code point.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.