HTML Entity Encoder / Decoder
Convert HTML special characters to safe entities and decode them back instantly
Input
Output
Settings
History (Last 20)
What is HTML Entity Encoding?
HTML entity encoding converts special characters into safe, displayable representations. This is essential when embedding HTML inside JavaScript strings, JSON responses, or database fields to prevent parsing errors and XSS vulnerabilities.
Common characters like <, >, &, ", and ' are encoded to prevent the browser from interpreting them as HTML markup.
Entity Types
Named Entities
Human-readable entity names:
< = <
> = >
& = &
" = "
' = 'Decimal Entities
Character codes in decimal format:
< = <
> = >
& = &Hexadecimal Entities
Character codes in hexadecimal format:
< = <
> = >
& = &Use Cases
- Embedding HTML inside JavaScript strings
- Storing HTML in JSON responses
- Preventing XSS attacks in web applications
- Displaying HTML code in documentation
- Storing HTML in database fields safely
- Creating HTML email templates
- Debugging HTML rendering issues
Features
- Encode HTML to safe entities (named, decimal, or hex)
- Decode HTML entities back to readable characters
- Auto-detect mode for smart encoding/decoding
- Live real-time transformation
- Character and entity counters
- Swap input/output for quick reversal
- Copy to clipboard with feedback
- Transformation history (last 20)
- Export results as text file
- Keyboard shortcuts for power users
- 100% client-side processing (no backend)
- Mobile responsive design
Examples
Example 1: Basic HTML
Input:
<div>Hello & Welcome</div>Output (Named):
<div>Hello & Welcome</div>Example 2: Comparison Operators
Input:
5 > 3 && 2 < 4Output (Decimal):
5 > 3 && 2 < 4Tips & Best Practices
- Use Named Entities: Most readable and widely supported
- Use Decimal/Hex for Special Characters: When named entities aren't available
- Always Encode User Input: Prevent XSS attacks in web applications
- Decode Before Display: Browsers automatically decode entities in HTML
- Test in Context: Verify encoding works in your specific use case
- Use Auto-Detect: Let the tool intelligently choose encode or decode
Related Tools
URL Encoder / Decoder
Encode and decode URLs with special characters. Convert to percent-encoded format instantly.
Base64 Encoder/Decoder
Encode text to Base64 or decode Base64 back to text instantly with file upload, auto-detect, and history
JSON Formatter & Beautifier
Beautify or minify JSON, highlight syntax errors, and explore nested structure with tree view.