HTML Entity Encoder & Decoder
Encode special characters (<, >, &, ", ') into HTML entity references (Named, Decimal, Hexadecimal) or decode HTML entities back to raw characters.
Encode & Decode HTML Entities
Enter text or HTML code to convert entity encodings instantly.
What are HTML Entities?
An HTML Entity is a character sequence used in HTML and XML to represent reserved characters, invisible spaces, and symbols that are not readily available on standard keyboards. In HTML syntax, characters such as <, >, &, and " have structural meaning—they define HTML tags, attributes, and script blocks. If you want a browser to display an actual less-than sign rather than opening a new HTML element, the character must be written as an entity reference (such as <).
Our free HTML Entity Encoder & Decoder gives you full control over character conversion. You can encode reserved characters into Named Entities (e.g., &), Decimal Entities (e.g., &), or Hexadecimal Entities (e.g., &), or decode entity-escaped markup back into raw, human-readable text.
How to Encode and Decode HTML Entities
- Enter Your Text or Code: Paste your HTML snippet, XML data, or raw text into the input box above.
- Choose Your Conversion Mode:
- Encode (Named Entities): Converts reserved symbols into readable named references (such as
<and©). - Encode (Decimal {): Converts characters into numeric decimal entity references (such as
<). Ideal for XML where named entities are restricted. - Encode (Hex {): Converts characters into hexadecimal numeric references (such as
<). - Decode Entities: Reverses entity codes back into raw HTML characters and symbols.
- Encode (Named Entities): Converts reserved symbols into readable named references (such as
- Copy or Download: Click Copy Output to copy the converted markup to your clipboard, or click Download TXT to save the file.
Common HTML Entities Quick Reference Cheat Sheet
The table below provides a quick reference for the most essential HTML entities used in web development:
| Character | Description | Named Entity | Decimal Entity | Hex Entity |
|---|---|---|---|---|
& |
Ampersand | & |
& |
& |
< |
Less Than | < |
< |
< |
> |
Greater Than | > |
> |
> |
" |
Double Quote | " |
" |
" |
' |
Single Quote / Apostrophe | ' |
' |
' |
|
Non-Breaking Space | |
  |
  |
© |
Copyright Symbol | © |
© |
© |
— |
Em Dash | — |
— |
— |
Real-World Use Cases for HTML Entity Encoding
- Displaying Code Snippets in Technical Tutorials: When publishing coding guides or developer blogs, enclosing raw tags like
<div>directly inside text causes browsers to render them as DOM elements. Encoding them into<div>ensures the actual code snippet displays visibly. - Cross-Site Scripting (XSS) Prevention: Sanitizing and escaping untrusted user input before outputting it into an HTML template prevents malicious script injection attacks (such as
<script>alert(1)</script>being executed). - XML and RSS Feed Validation: Strict XML parsers fail with fatal errors if text contains raw ampersands (
&) or angle brackets. Encoding these characters into entity references guarantees XML well-formedness. - HTML Email Template Compatibility: Email clients (like Microsoft Outlook) handle complex Unicode characters inconsistently. Using numeric HTML entities ensures symbols like copyright (
©) or currency marks render consistently across all inboxes. - Decoding Scraped Markup: When scraping web pages or consuming third-party API data, text often arrives entity-encoded. The decode feature quickly restores natural human-readable sentences.
Named vs. Decimal vs. Hexadecimal: Which Should You Use?
Each entity format has specific technical strengths:
- Named Entities: Easiest for humans to read and remember (e.g.,
©for © or™for ™). Supported across all modern HTML5 browsers. - Decimal & Hex Entities: Rely on Unicode code points (such as
—). Because standard XML only recognizes five named entities (",&,',<, and>), numeric decimal and hex entities are strictly required for XML, SVG, and RSS documents.
Looking for complementary encoding and text tools? Try our companion URL Decoder & Encoder, encode binary data with the Base64 Encoder, inspect byte values with the Text to Binary Converter, or strip HTML tags with the Text Cleaner.
Frequently Asked Questions
Which characters MUST be escaped in standard HTML?
The four essential characters that must always be escaped in HTML body text and attributes are: ampersand (& → &), less-than (< → <), greater-than (> → >), and double quote in attributes (" → ").
What is the difference between named, decimal, and hexadecimal entities?
Named entities use mnemonic English words (like <), making them easy for developers to recognize. Decimal (<) and hexadecimal (<) entities use the character's numerical Unicode code point, ensuring universal compatibility across XML, SVG, and legacy rendering engines.
Does encoding HTML entities prevent Cross-Site Scripting (XSS)?
Yes. By converting characters like <, >, and & into entity references, browsers treat user-supplied input as harmless text rather than executable markup or JavaScript.
Why does an unescaped ampersand (&) break HTML validators?
In HTML syntax, the ampersand character (&) is reserved exclusively to start an entity reference. When a browser encounters an isolated & followed by plain text, it attempts to parse it as an entity, triggering parsing warnings and validator errors.
Can this tool decode HTML entities back into regular characters?
Yes. Simply paste your entity-encoded HTML into the tool and click Decode Entities. All named, decimal, and hex entity codes are instantly converted back into readable characters.
Explore More Free Text & Conversion Tools
Fast, secure, and easy-to-use online text utilities built for creators and developers.
Text Case Converter
Convert text between UPPERCASE, lowercase, Title Case, Sentence case and Capitalized case.
Character Counter
Count total characters with and without spaces, words, sentences, and lines in real-time.
Word Counter Online
Accurately count words, unique vocabulary, characters, reading time, and word frequency.
Sentence Counter
Count sentences accurately, calculate average sentence length and readability metrics.
Reading Time Calculator
Estimate reading and speaking time based on custom WPM reading speeds.
Decimal to Hex Converter
Convert base-10 decimal numbers to hexadecimal format with prefix and padding controls.
Text Reverser
Reverse text characters, word order, line order, or flip text upside down instantly.
Letter Counter
Accurately count total letters (A-Z), vowels, consonants, and analyze letter frequencies.
Line Counter
Count total lines, non-empty lines, empty lines, and add line numbers automatically.
Text Cleaner
Clean duplicate spaces, strip HTML tags, remove empty lines, symbols, and numbers.
Alphabetical Order Sorter
Sort lines or words alphabetically (A-Z / Z-A), remove duplicates, or sort by length.
Line Break Remover
Remove newlines, replace breaks with custom delimiters, and preserve paragraphs.
Title Capitalization Tool
Convert text into proper title case following AP Style and Chicago style guidelines.
Text Formatter
Format line prefixes, suffixes, paragraph indentations, and sentence spacing.
Whitespace Remover
Remove all spaces, collapse multiple spaces, trim lines, and remove tab characters.
Word Frequency Counter
Analyze word frequency counts, filter stop words, and sort vocabulary density.
HTML Entity Encoder
Encode special HTML characters into Named, Decimal, or Hexadecimal HTML entities.
Base64 Encoder
Encode UTF-8 text or strings into standard or URL-safe Base64 format.
Base64 Decoder
Decode Base64 string data back to readable UTF-8 text with input error validation.
URL Decoder
Decode URL-encoded strings, percent encodings, and parse query parameters.
Text to Binary Converter
Convert plain text strings into 8-bit binary code (0s and 1s) with UTF-8 byte encoding.