About this html entity converter
Convert between readable text and HTML character references. Encoding replaces characters such as ampersands and angle brackets with references that can be placed in HTML text safely. Decoding recognizes named references, decimal numeric references and hexadecimal numeric references. For example, & becomes an ampersand when decoded, while 😀 becomes a smiling emoji. The selected direction determines whether existing references are interpreted or encoded as literal text.
The locally packaged he parser supports the extensive named-reference table used by HTML, rather than only replacing five familiar entities. Encoding favors named references when available, with numeric references for other characters that need representation. Decoding follows the library's HTML text behavior and can accept some references without a final semicolon. For predictable source code, include semicolons when writing character references yourself.
Entity decoding can turn harmless-looking text into angle brackets and other markup characters. The result is kept in a text field on this page; if another application inserts decoded output as HTML, it must apply the appropriate sanitization or escaping policy for that context. Text escaping alone is not a universal URL or JavaScript escaping mechanism.
Which controls should I check first?
The HTML Entity Converter form labels its controls as Input; Direction; Result. Its selectable values include Decode entities; Encode text. Use those labels to keep the source and settings separate. A sample argument that selects a mode is not additional source text. Choose the setting matching your intended operation before copying a result, and change it explicitly when comparing another mode. The labels describe what this form accepts; the worked examples below demonstrate only the stated supplied values.
How should I interpret this specific operation?
An entity represents a character, not necessarily a complete HTML element. Decoding & produces an ampersand, while encoding a literal angle bracket prevents it from being interpreted as markup in the relevant text context. Do not decode before combining untrusted text with a template, because that can reintroduce structural characters. Check the direction of the selected mode before copying the result.
Worked helper values
These values come from the reproducible calculation examples supplied with this tool. Each row identifies the complete supplied arguments and the returned value. A visible ↵ denotes a line break and ⇥ denotes a tab in text examples. Settings appear alongside source data so that a different mode is not mistaken for an identical input. These are helper calculations, not observations of a live device, fetched target, image decoder, browser preview or downloaded file. Use the stated method above to relate the returned fields to the actual operation.
| Supplied values | Calculated return value |
|---|---|
| & 😀; decode | & 😀 |
| <; encode | < |
Is this a representation change or a content change?
An encoding expresses bytes or characters using a different alphabet or escape notation. It should not be confused with encryption, compression or permission to execute the result. Work out which layer the receiving field expects before converting. A URL component, a complete URL, an HTML text node and a JSON string need different escaping rules. Encoding for one context does not automatically make a value safe in another. Keep the unencoded source while editing and convert at the boundary where the destination requires it. Otherwise repeated conversions can encode existing escape markers rather than the original content.
How do I diagnose a malformed input?
Check the alphabet, prefix, separators and final padding against this tool's documented input format. A pasted quotation mark or trailing label can turn a valid payload into invalid text. For UTF-8 decoding, a byte sequence can be syntactically valid in its outer representation yet still fail to represent text. Binary images and compressed data are examples of payloads that should not be forced through a text decoder. Use the appropriate file or image workflow for them. Do not remove padding or percent signs at random to make an error disappear; first identify what those characters mean in the expected representation.
Why does decoding once matter?
A value can have more than one encoding layer. Decoding the outer layer yields another encoded string rather than necessarily reaching the final readable content. Repeating the operation is appropriate only when the source format specifies those layers. With URL components, decoding separator characters too early can change the structure of a query. With HTML entities, a decoded angle bracket is ordinary text until another application interprets it as markup. Inspect the result as text before placing it into an active context. Keep a record of which layer you decoded so that a later step does not accidentally repeat it.
How do non-ASCII characters affect the result?
A character such as é occupies more than one UTF-8 byte. An emoji can require several bytes even when it occupies one visible position. Encoders process those bytes according to their representation rules, so output length cannot be predicted from visible character count alone. A percent-encoded character can consist of several percent triplets, and Base64 groups bytes rather than visible letters. Compare the worked Unicode example with the result instead of assuming one output group per character. A strict text decoder helps expose damaged bytes that would otherwise be replaced by an ambiguous replacement character.
Are numeric references supported?
Yes, both decimal and hexadecimal references.
Does it support emoji?
Yes. Numeric references can represent Unicode code points beyond the basic multilingual plane.
Is decoded text safe as HTML?
Not automatically. Escape or sanitize it for the destination context.