HTML Entity Encoder / Decoder
Encode special characters to HTML entities or decode HTML entities back to text. Supports named, numeric, and hex formats.
Common HTML Entities Reference
How to Use
- Select Encode or Decode mode.
- For encoding, choose the entity format: Named, Numeric, or Hex.
- Paste your text into the input panel.
- Click Encode or Decode to process.
- Click Copy to copy the result.
Why Encode HTML Entities?
HTML entity encoding is critical for web security and correct rendering. Without encoding, characters like <, >, and & are interpreted as HTML markup rather than displayed as text. This is the foundation of XSS (Cross-Site Scripting) prevention — any user-supplied text displayed in HTML must have these characters encoded.
Essential HTML Entities
- & — Ampersand (&) — must always be encoded in HTML
- < and > — Less-than and greater-than signs
- " — Double quote — important in HTML attributes
- — Non-breaking space — prevents line breaks between words
- © — Copyright symbol (©)
- — — Em dash (—)
Encoding in Different Contexts
The encoding rules differ by context. In HTML body text, encode < > &. In HTML attributes, also encode " and '. In URLs, use percent-encoding instead (see the URL Encoder). In JavaScript strings within HTML, use both HTML entity encoding and JavaScript escaping.
Related Tools
Encode URLs with the URL Encoder. Escape strings for JavaScript, SQL, and more with the String Escape Tool. Encode/decode Base64 with the Base64 Tool. Format HTML with the HTML Beautifier. Test patterns with the Regex Tester. Format embedded JSON with the JSON Formatter. Minify JavaScript or CSS alongside HTML content.
Frequently Asked Questions
- What are HTML entities?
- HTML entities are special codes that represent characters that have special meaning in HTML (like < > & ") or characters not available on a standard keyboard (like © ™ →). They start with & and end with ;
- What is the difference between named, numeric, and hex entities?
- Named entities use human-readable names (&amp;). Numeric entities use decimal code points (&#38;). Hex entities use hexadecimal code points (&#x26;). All three represent the same characters — named entities are most readable, while numeric/hex work for any Unicode character.
- When should I encode HTML entities?
- Encode HTML entities when displaying user-generated content to prevent XSS attacks, when including special characters in HTML attributes, or when you need to display HTML tags as visible text rather than rendered markup.
- Is my data safe?
- Yes. All encoding and decoding happens entirely in your browser. No data is sent to any server.
Code Examples
Learn how to use this tool programmatically in your favorite language.
Use this tool from AI agents.
The CodeTidy MCP Server lets Claude, Cursor, and other AI agents
use this tool and 46 others directly. One command: npx @codetidy/mcp