HTML Entities Encoder & Decoder
Escape special HTML characters so they're safe to embed in web pages, or reverse the process to decode entity references back to readable text. Optional numeric entity mode encodes every non-ASCII character to ensure maximum compatibility with legacy systems, email clients, and specific character encodings.
What does this tool do?
The HTML Entities tool provides bidirectional conversion between special characters and their HTML entity representations. Encoding converts characters like < > & " to their entity forms (< > & ") so they display correctly in HTML rather than being interpreted as markup. Decoding reverses entity references back to the actual characters. The optional numeric entity mode (&#[decimal];) encodes all non-ASCII characters, useful for systems that don't properly handle UTF-8.
How it works
Encoding uses a character mapping table for the five essential XML/HTML entities and their named forms: & → &, < → <, > → >, " → ", ' → '. When numeric mode is enabled, characters outside the ASCII printable range are converted to &#NNNN; decimal entity references. Decoding uses regex to find entity patterns (named: &name; numeric: &#NN; or &#xNN;) and maps them back to Unicode characters via HTML entity tables and parseInt for numeric values. All processing is done client-side with no server interaction.
Features
- Encode < > & " ' to named entities
- Optional numeric entities (&#NN;) for non-ASCII
- Decode named, decimal, and hex entities back to text
- Live conversion as you type
- 100% client-side processing
- Handles all standard HTML4 and HTML5 entity names
- Preserves text when copying between contexts
How to use
- 1
Paste your input
Enter plain text to encode, or HTML-escaped text with entities to decode. The tool auto-detects content type or you can switch modes manually.
- 2
Select encode or decode
Choose Encode to make text safe for HTML, or Decode to convert entities back to readable characters.
- 3
Toggle numeric entities (encode)
Enable numeric entities to encode all non-ASCII as &#NNNN; — useful for email or legacy systems that may mangle UTF-8.
- 4
Copy result
Grab the encoded text for your HTML source, or the decoded text for normal reading and editing.
Common use cases
Embed code in HTML
Encode < and > in code examples so they display correctly rather than being parsed as HTML tags by browsers.
Email content preparation
Use numeric entities for email HTML to maximize compatibility with various email clients that handle character encodings inconsistently.
Debugging scraped content
Decode entity references in web-scraped content to see the actual text, or encode user input before inserting into HTML templates.
Legacy system compatibility
Encode to numeric entities for systems that don't properly support UTF-8, ensuring characters display correctly regardless of encoding settings.
Tips & best practices
- Always encode & to & first in the processing chain — otherwise encoded entities like < would become &lt;
- For modern web with charset=utf-8, named entities for < > & " ' are sufficient; numeric entities for all characters are usually unnecessary
- Email HTML benefits from numeric entities due to inconsistent UTF-8 handling across email clients
- The five essential entities are: & (&), < (<), > (>), " ("), ' (') — encode these for any HTML context