HTML character references represent characters using text that begins with an ampersand. Encoding characters such as ampersand and less-than can keep text from being interpreted as markup in the right HTML context; decoding turns references back into readable characters.
Common HTML entities
| Character | Named reference | Numeric reference |
|---|---|---|
| & | & | & |
| < | < | < |
| > | > | > |
| " | " | " |
| ' | ' | ' |
Encode HTML text online
- Open the HTML Escape and Unescape Tool.
- Paste the plain text.
- Choose encode or escape.
- Copy the result.
- Insert it only into the context the encoding was prepared for.
For example, plain text Tom & Ana <3 becomes Tom & Ana <3 when displayed as HTML text.
Decode HTML entities
Use decode when imported text contains references such as & or © and you need the displayed characters. Decode only as many times as the workflow requires. Repeated decoding can turn deliberately escaped text into active markup when it is later inserted unsafely.
HTML encoding depends on context
Escaping for an HTML text node is not the same as safely building an attribute, URL, CSS rule, or JavaScript string. Prefer DOM APIs such as textContent for untrusted text and use a well-reviewed context-aware templating system. An entity converter is a text utility, not a complete cross-site-scripting defense.
HTML entities are not URL encoding
HTML references use forms such as &. URL percent-encoding uses byte values such as %20. Use the URL Encoder/Decoder for URL components. Applying the wrong encoding can damage data or create security bugs.
Use UTF-8 for ordinary characters
Modern HTML documents should declare UTF-8, allowing most language characters and symbols to appear directly. Character references remain useful for HTML-sensitive punctuation, invisible characters, and cases where a reference improves clarity in source code.
Frequently asked questions
Should every non-ASCII character become an entity?
No. In a UTF-8 HTML document, ordinary language characters can usually appear directly. Escape markup-sensitive characters when required by context and use numeric references for special cases where they improve reliability or clarity.
Why do I see & on a page?
The text was probably encoded twice. The first pass changed an ampersand to &, and the next pass escaped that new ampersand again. Track where encoding occurs and apply it once at the output boundary.
Is decoding user input safe?
Decoding can reactivate markup characters. Keep untrusted content as text with DOM text APIs or context-aware escaping. Do not decode and insert the result with an unsafe HTML sink such as unreviewed innerHTML.
Are and a normal space identical?
No. The non-breaking-space reference prevents an ordinary line break at that position and is a distinct Unicode character. Use it only when the content genuinely must stay together; CSS layout is usually better for visual spacing.
Sources checked
Character-reference syntax and the named entity list were compared with the WHATWG material on August 12, 2026; use the live standard for parser edge cases.