gizmobench
BrowseDaily

HTML Encoder

This page opens Encode: type in the Text box and read the escaped result in Entities. Named and Numeric cover markup characters and non-ASCII text; Markup only escapes the five markup characters while retaining accents and emoji. The result stays text and can be copied into a suitable HTML text or attribute context.

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

Which encoding policy should I choose?
Named writes the known name where available and decimal references otherwise. Numeric writes decimal references for the same covered characters. Markup only escapes ampersand, less-than, greater-than and both quotes, leaving other Unicode text unchanged. None of the policies is a complete JavaScript, CSS, URL or JSON escaping function.
Does the preset replace my remembered direction or policy?
It opens Encode while retaining your remembered policy. Editing text alone does not replace a direction supplied by the preset in saved settings. Selecting Encode or Decode, including the current control, explicitly saves that choice. Selecting a policy saves that policy.
Can I use this to encode an email address or hexadecimal entities?
The text can be written as references, but that is not email delivery validation or spam protection. Numeric output is decimal; hexadecimal references can be decoded and looked up in the parent chart, but there is no hexadecimal-output option.

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.