HTML Encoder / Decoder
Convert HTML tags and special characters to safe display format (e.g., < → <) or decode them back to HTML. Essential for displaying HTML code safely.
Input Settings
No input entered
Encoded Result
Encoded result will appear here
Enter HTML and click "Convert" to start
Sample HTML
Common HTML Entities
About HTML Encoder / Decoder
HTML encoding converts HTML special characters and tags into HTML entities that can be safely displayed in web browsers without being interpreted as actual HTML markup. This tool transforms characters like <, >, &, quotes, slash, backtick and equals into their corresponding HTML entities (<, >, &, etc.) and can also decode these entities back to their original characters.
Why use a HTML Encoder / Decoder?
HTML encoding is crucial for preventing XSS (Cross-Site Scripting) attacks and ensuring that HTML code displays correctly as text rather than being executed by the browser. It allows you to safely display user-generated content, code examples, or HTML snippets on web pages without compromising security or breaking the page layout.
Who is it for?
Web developers, content management system developers, security professionals, and technical writers who need to display HTML code safely on web pages will find this tool essential. It's particularly valuable for developers building forums, documentation sites, code sharing platforms, or any application that handles user-generated content.
How to use the tool
Enter your HTML code or text containing special characters in the input field
Choose 'Encode' to convert HTML characters to safe entities, or 'Decode' to convert HTML entities back to readable characters
Click Convert to process your content
Copy the encoded or decoded result from the output area
Use the converted content safely in your web pages or applications
Frequently Asked Questions
How do I encode/decode HTML entities?
Choose Encode or Decode and click Convert. Encoding replaces & < > " ' / ` and = with entities (& < > " ' / ` =); the format is fixed, with no option to choose named or numeric entities. Decoding converts every numeric entity (& and &) and every named HTML5 entity (©, ♥) back to its character in a single pass, so &lt; becomes < rather than <. Unknown names are left unchanged. Useful for: safely embedding user-input text in HTML, preparing content for blog posts, inspecting HTML source. Runs entirely in your browser — your input never leaves the device.
What are HTML entities?
HTML entities are special character sequences used to represent characters that would otherwise be interpreted as HTML syntax. Five characters are critical: `<` (<), `>` (>), `&` (&), `"` (") and the apostrophe (`'` or `'`). HTML defines hundreds more (` ` non-breaking space, `©` ©, `♥` ♥, etc.). Numeric entities can represent any Unicode codepoint: `A` = 'A', `😀` = 😀. Entities ensure characters render as text, not as HTML markup.
Is my data sent to a server when I encode?
No — encoding/decoding runs entirely in your browser via JavaScript. Your input never reaches a server, never gets logged. Verify in DevTools' Network tab: zero HTTP requests during encoding. Safe for processing user-generated content, draft blog posts, sensitive HTML snippets. The encoding is deterministic; no server processing needed.
When should I HTML-encode user input?
Always, before inserting into HTML output. This is the primary defence against Cross-Site Scripting (XSS): if a user submits `<script>alert(1)</script>` as a comment, HTML-encoding turns it into `<script>alert(1)</script>` — the browser displays it as literal text instead of executing the script. Modern frameworks (React, Vue, Angular) auto-escape by default; vanilla HTML/PHP needs explicit calls (PHP `htmlspecialchars()`, Node `he.encode()`). See [User Input Sanitizer Tester](/tools/user-input-sanitizer-tester/) and [XSS Payload Tester](/tools/xss-payload-tester/) for context.
What's the difference between named and numeric entities?
Named entities (`&`, `<`, `©`, `♥`) are human-readable but limited to the predefined HTML named-entity list (~250 named entities). Numeric entities (`A` decimal or `A` hex) can represent any Unicode codepoint (over 144,000 characters). Use named entities when available for readability; use numeric entities for characters without named versions (emoji, rare scripts, etc.). The HTML5 spec ensures decoders handle both, and this tool's decoder accepts both (the encoder only produces the fixed set described above). For pure XML (not HTML), the named entity list is smaller — only 5 core entities (`amp`, `lt`, `gt`, `quot`, `apos`).
Does this handle Unicode and emoji?
Decoding has full Unicode support: emoji like `😀` (decimal) or `😀` (hex) resolve correctly, as do named entities. Encoding does not convert non-ASCII characters or emoji to entities; it leaves them as they are, which is correct for UTF-8 pages. Note: the actual display depends on the consumer's font and platform — emoji that exist in Unicode but lack font support display as boxes or fallback glyphs. The encoding/decoding is correct regardless of display.
What's the difference between HTML and URL encoding?
Different contexts, different rules. HTML encoding (this tool) converts `<>&"'` to entities — for embedding in HTML/XML markup. URL encoding (use [URL Encoder/Decoder](/tools/url-encoder-decoder/)) converts non-URL-safe characters to `%XX` percent-escapes — for embedding in URLs and HTTP requests. Space: HTML doesn't encode it; URL encodes to `%20` (or `+` in query strings). They're not interchangeable — using URL encoding inside HTML content causes display errors; using HTML entities inside URLs creates wrong URLs.
Why are some characters left unencoded?
The encoder only replaces `& < > " ' / ` =`. Other characters (letters, digits, punctuation, even Unicode) display correctly in HTML without entities — encoding them just bloats the output. The encoder's scope is XSS-prevention + valid HTML output, not 'encode everything', and there is no mode that encodes all non-ASCII characters. For modern UTF-8 HTML, only the core five entities matter.
Share This Tool
Found this tool helpful? Share it with others who might benefit from it!
💡 Help others discover useful tools! Sharing helps us keep these tools free and accessible to everyone.