About the Text to HTML Entities Converter
Encoding exists to stop a character being read as structure. An ampersand starts a reference, a less than sign starts a tag, and a quote can close an attribute early, so any text placed into markup has to have those characters replaced before it gets there. Everything else is optional, and the three scopes here reflect how far people actually go.
Markup characters only touches the five that matter, which is the correct default for a UTF-8 page and keeps the result readable. Markup and non ASCII additionally encodes accented letters, currency symbols, typographic quotes and emoji, which is what you need for an email template, a legacy system that mangles anything above code point 127, or a file whose encoding you do not control. Every character encodes the lot except spaces and line breaks, the brute force option for obfuscating an address in page source.
The format switch decides how each replacement is written. Named entities such as é and € are easy to recognise while reading source but exist only for a fixed list. Decimal and hexadecimal numeric references cover every code point in Unicode, and hexadecimal has the advantage that the number matches the U+ notation in the character charts. Characters outside the basic plane, emoji among them, are encoded as one reference from their real code point rather than as a surrogate pair, so the result decodes correctly everywhere. Real line breaks are kept by default, since encoding them makes the output unreadable without changing what a browser displays. Reverse it with HTML Entities to Text.
How to use
- Paste the text you need to make safe for markup.
- Choose how far to go under Encode. Markup characters only is right for most modern pages.
- Pick Named for readable source, or Hexadecimal to match the U+ notation in Unicode charts.
- Press Encode and paste the result into your template.
Common questions
- Do I need to encode accents on a UTF-8 page?
- No. Declare the charset and é works as itself. Encode them only when the file passes through a system that cannot be trusted with non ASCII bytes.
- Which format should I choose?
- Named entities read better in source; numeric ones cover every character. If a name does not exist for a character, the tool falls back to a numeric reference automatically.
- How are emoji encoded?
- As a single reference built from the real code point, for example the hexadecimal form of U+1F600, rather than as two surrogate values.
- Is this the same as URL encoding?
- No. Entities are for HTML documents. Percent encoding is for addresses, and the two are not interchangeable.