Source code guides

Read HTML character references in their original context

·

An HTML reference gives a character another spelling in source. Knowing whether the spelling occurred in text or an attribute matters for older input that omits semicolons.

HTML Entity Encoder and Decoder

Encode and recover a Unicode character

Select hexadecimal references and enter 😀. Copy 😀 into Decode references and select Require semicolons. The result is the original emoji. For a paragraph containing A & B, the special-character option escapes the ampersand while keeping ordinary letters readable.

HTML Living Standard — named character references

Compare a legacy reference

Decode &copycat with HTML text rules. The result is ©cat. Choose HTML attribute and repeat. The following letter prevents the unterminated reference from being interpreted in that context. Require semicolons also preserves the original spelling.

HTML Living Standard — parsing HTML

Check whether markup was already escaped

An editor displaying the five literal characters & may contain an escaped ampersand. Decode once and inspect the result before decoding it again. A second pass can turn text intended for display into markup-looking characters.

When placing the result in a web page, use a text context if it should remain visible as text. Entity conversion changes how characters are represented and does not establish that user-supplied HTML is safe to insert.

Common questions

Why does < decode to <?

One pass decodes the ampersand reference. A second pass converts the resulting less-than reference. Apply the second pass only when the source was escaped twice.

Can the decoded text execute as HTML?

The result appears in a plain-text field and downloads as a text file. If you insert it into another application, use the escaping rules for that destination.

Sources

Put it into practice.

Related guides