gizmobench

HTML Encoder

Paste text to convert characters that HTML treats as markup into safe entities. The result is generated locally and is ready to copy into source code.

Direction
Entities
7
Length
50
Policy

Encoding with names: the five markup characters and everything outside plain ASCII are written as references, using the HTML name where there is one and a number where there is not. Every other character is left as it was.

Worked examples

  • Named referencesé &
    Ă© &
  • A number😀
    😀
  • Escaped twice< loses one layer
    <
  • Encode with names<p>CafĂ©</p>
    &lt;p&gt;Caf&eacute;&lt;/p&gt;
  • Out of range&#x110000;
    &#x110000; at position 1 asks for a number above U+10FFFF, the highest code point Unicode defines, so it decodes to the replacement character U+FFFD.

Type in either box: editing the entities side decodes, editing the text side encodes. Swap sends the text you have to the other box, which is the fix for a paste that went in the wrong one. Positions count characters from the start of the box, beginning at 1, and an emoji counts as one character.

What gets decoded, and what is left alone. A reference is decoded when it ends in a semicolon: &eacute; and &#233; both become the same letter, and names are case sensitive, so &Eacute; is the capital. Anything else is left as the text it already was and listed above with its position: a name this tool does not carry, a reference with no semicolon after it, or a number that no character answers to. The table holds the HTML 4 named references, which is the set browsers have always agreed on; numeric references work for every code point, whether or not they have a name. The decoding runs once, so &amp;lt; becomes the four characters &lt; and stops there.
Accuracy. Decoding is done by an inert parser that never runs the markup, and the result is always text rather than something the page renders. Encoding covers the characters you choose, and every other character is left exactly as it was.

Common questions

Does this run in my browser?
Yes. The page performs the core transformation in your browser and explains the result before you copy or download it.

Decoding is done by an inert parser that never runs the markup, and the result is always text rather than something the page renders. Encoding covers the characters you choose, and every other character is left exactly as it was.