HTML Entities
Convert between plain text and HTML entities: encode as named entities or decimal / hex numeric references, escaping only HTML-unsafe characters or all non-ASCII; decode &name;, &#NN; and &#xNN; references back to characters (astral/Emoji safe).
Named: prefer a named entity, fall back to numeric.
How to use
Purpose
Online HTML entity encoder/decoder. Converts < > & " ' to entities (< > & " ') and back. Supports named entities (© —) and numeric entities (   ). Common for safely embedding user input in HTML (XSS defense), displaying code in blogs, and HTML email compatibility. All conversion runs locally.
Steps
- Paste HTML or text with special characters
- Click Encode to convert < > & " ' to entity forms
- Reverse: paste entity-containing text and click Decode
- Modes: Basic (just the 5 core characters), All (encode all non-ASCII), Named entities (© instead of ©)
- Numeric entity format: decimal (©) or hex (©)
- Newline handling: optionally convert \n to <br />
- Quick reference: (non-break space),   (em-space), — (em dash), … (ellipsis)
FAQ
- Which characters MUST be HTML-encoded?
- The 5 core: < (<), > (>), & (&), " ("), ' (' or '). Other characters (CJK, digits, spaces) in UTF-8 docs do not need escaping. Failing to encode the 5 causes HTML parsing breaks or XSS vulnerabilities.
- Is HTML entity encoding enough for XSS defense?
- No. HTML entities only protect injection into HTML text. Attribute values, JavaScript contexts, URLs, and CSS each have their own encoding rules. Full XSS defense: 1) HTML text → HTML entities; 2) HTML attributes → attribute-specific encoding; 3) JS strings → \uXXXX; 4) URLs → percent encoding. Libraries like DOMPurify automate this.
- What is and how is it different from a regular space?
- is a non-breaking space (U+00A0). A regular space lets the line wrap; does not. Uses: 1) keep "10 km" together; 2) preserve consecutive spaces (HTML collapses runs of normal spaces, not nbsp); 3) typography micro-adjustments.
- Should I use named entities (©) or numeric (©)?
- Modern HTML5 prefers writing © directly (UTF-8 supports it). If you must escape: named entities are readable but only ~250 have names. Numeric covers all of Unicode but is unreadable. For XML / strict use, numeric (© hex) is more portable.
- Why does my code snippet with <script> execute on my blog?
- The platform did not escape it. You need <script> instead of <script>. The Encode button does this. Or use Markdown code fences (```) — renderers auto-escape. Rich-text editors (CKEditor, TinyMCE) lose escaping when pasting code as a normal paragraph; use "insert code block" instead.
Use cases
- XSS defense: encode user input before injecting into HTML
- Code display on blogs: convert <html> to <html> so browsers do not execute it
- HTML email: convert CJK / special chars to entities for legacy email clients
- Scrape cleanup: decode entities in scraped HTML to recover readable content
- Generating RSS/Atom: & must become & or XML parsers fail
Use cases
XSS defense, displaying code in blogs, HTML email compatibility, scrape cleanup, RSS/Atom generation. Frontend, backend, scrapers, email marketing, technical bloggers. Basic/All/Named modes and decimal/hex numeric entities are the differentiators.