54+ Local Tools Available
100% Browser Execution (No Uploads)
Zero Latency Instant Output
100% Private & Secure
Developer & Data Client Local

Html Entity Converter

Client-side Html Entity Converter tool running 100% in browser.

Quick Sample Templates:
0 chars0 bytesSize Change: -
Converted Output (Converted Output)

Entity Conversion Options (Options)

Frequently Used Standard Entities (Click to Insert)

CharNamedDec
&&&
<&lt;&#60;
>&gt;&#62;
"&quot;&#34;
'&apos;&#39;
©&copy;&#169;
®&reg;&#174;
&trade;&#8482;

Click any row in the table below to insert its entity directly at your editor cursor position.

HTML Entity Essentials

5 Core Reserved Characters: & (&amp;), < (&lt;), > (&gt;), " (&quot;), ' (&apos; or &#39;) must always be escaped in HTML markup to prevent parser syntax errors.

Named vs Decimal vs Hex: &copy; (Named), &#169; (Decimal), and &#xA9; (Hex) all render the exact same © glyph in web browsers.

Core XSS Defense: Rendering unsanitized user inputs via innerHTML without entity encoding exposes applications to Cross-Site Scripting vulnerabilities.

Input source code, passwords, and sensitive HTML markup are never transmitted to a cloud server. All parsing happens in local browser JavaScript DOM memory.

Web Standards & HTML5 Security Specifications

Technical Principles of HTML Entities & XSS Mitigation

HTML (HyperText Markup Language) defines document structures using angle brackets (< >), ampersands (&), and quotation marks (" ') as reserved syntax delimiters for tags and attributes.

If raw user inputs containing <script> or & are rendered directly in HTML, the browser parser misinterprets them as markup tags or entity prefixes. This can break layout structures or allow malicious scripts to execute (Cross-Site Scripting / XSS).

HTML character entity references provide a standardized W3C mechanism (&name; or &#code;) to render reserved characters and Unicode symbols safely without parser interference.

Full Support for Named, Decimal & Hex Formats

Toggle between human-readable Named entities (&amp;), W3C Decimal (&#38;), and Hexadecimal (&#x26;) formats.

5 Core Characters vs Non-ASCII Scopes

Choose between standard XSS defense mode (5 core characters) and full non-ASCII Unicode symbol encoding.

Interactive Common Entities Reference Table

Browse currency symbols, math operators, and copyright marks with one-click insertion at your cursor.

Safe DOM-Based Unescape Engine

Leverages browser native DOMParser algorithms to accurately restore all complex entity codes to raw text.

1. The 5 Core Reserved HTML Characters That Must Be Escaped

Ampersand (& \to &amp; / &#38;):
- In HTML, & signals the start of an entity. Writing Tom & Jerry can cause parsing errors if the parser attempts to resolve &Jerry;. It must be written as &amp;.
Less Than (< \to &lt; / &#60;):
- Signals the opening of an HTML tag (<div, <script>). Failing to escape < allows arbitrary tag injection and script execution.
Greater Than (> \to &gt; / &#62;):
- Closes HTML tags. Escaped as &gt; to prevent premature tag closing and attribute breakouts.
Double Quote (" \to &quot; / &#34;):
- Encloses HTML attribute values (<input value="user_input">). Unescaped quotes allow attackers to inject malicious event handlers like onload= or onerror=.
Single Quote (' \to &#39; or &apos;):
- Used for attribute values and inline JavaScript string literals. Decimal &#39; is recommended for broad legacy browser compatibility.

2. HTML Entity Formats Specification Comparison Table

Reference table comparing Named, Decimal, and Hex representations for common symbols.

CharacterDescription & RoleNamed EntityDecimalHexadecimal
&Ampersand&amp;&#38;&#x26;
<Less Than&lt;&#60;&#x3C;
>Greater Than&gt;&#62;&#x3E;
"Double Quote&quot;&#34;&#x22;
'Single Quote&apos; (or &#39;)&#39;&#x27;
©Copyright Symbol&copy;&#169;&#xA9;
®Registered Trademark&reg;&#174;&#xAE;
Trademark Symbol&trade;&#8482;&#x2122;
Euro Currency Symbol&euro;&#8364;&#x20AC;
Non-breaking space&nbsp;&#160;&#xA0;

3. Web Security: XSS Mitigation Principles & Browser DOM Rendering

DOM Text Node vs innerHTML Rendering:
- When a browser assigns element.textContent = str, the string is treated strictly as plain text, preventing script execution.
- When using element.innerHTML = str, the HTML parser executes markup. If the input contains <img src=x onerror=alert(1)>, malicious JavaScript executes immediately.
- Modern frontend frameworks (React, Vue, Angular) automatically escape HTML entities by default when binding variables in templates.
Attribute Context Escaping:
- In <input value="${userInput}">, entering " escapes the attribute context to inject event handlers unless quotes are converted to &quot;.

4. Implementation Patterns Across Programming Languages

JavaScript / TypeScript: Regex mapping or native DOMParser API.
Python 3: Standard library html.escape() and html.unescape().
Java: Apache Commons Text StringEscapeUtils.escapeHtml4() or custom replacement.
PHP: Built-in htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, "UTF-8").
C# (.NET): Standard System.Net.WebUtility.HtmlEncode() and HtmlDecode().

Developer Implementation Snippets for HTML Entity Encoding & Decoding

Production-ready code snippets across JavaScript, Python, PHP, Java, C#, and Go.

JavaScript / TypeScript
1// 1. Escape 5 core reserved characters (XSS Prevention)
2function escapeHTML(str: string): string {
3 const entityMap: Record<string, string> = {
4 '&': '&amp;',
5 '<': '&lt;',
6 '>': '&gt;',
7 '"': '&quot;',
8 "'": '&#39;',
9 };
10 return str.replace(/[&<>"']/g, (s) => entityMap[s]);
11}
12 
13// 2. Decode HTML entities via DOMParser
14function unescapeHTML(html: string): string {
15 const doc = new DOMParser().parseFromString(html, 'text/html');
16 return doc.documentElement.textContent || '';
17}
18 
19const raw = '<script>alert("XSS & Hello!");</script>';
20const encoded = escapeHTML(raw);
21console.log("Encoded:", encoded);
22// Output: &lt;script&gt;alert(&quot;XSS &amp; Hello!&quot;);&lt;/script&gt;
23 
24const decoded = unescapeHTML(encoded);
25console.log("Decoded:", decoded);
Python 3
1import html
2 
3# 1. HTML Entity Encoding
4raw_text = '<div class="banner">Hello & Welcome!</div>'
5encoded = html.escape(raw_text, quote=True)
6print("Encoded:", encoded)
7# Output: &lt;div class=&quot;banner&quot;&gt;Hello &amp; Welcome!&lt;/div&gt;
8 
9# 2. HTML Entity Decoding
10decoded = html.unescape(encoded)
11print("Decoded:", decoded)
PHP
1<?php
2$raw = '<a href="test.php?id=1&name=Tom">Click & "Go"</a>';
3 
4// 1. htmlspecialchars (escapes double and single quotes)
5$encoded = htmlspecialchars($raw, ENT_QUOTES | ENT_HTML5, 'UTF-8');
6echo "Encoded: " . $encoded . "\n";
7 
8// 2. htmlspecialchars_decode (decoding)
9$decoded = htmlspecialchars_decode($encoded, ENT_QUOTES | ENT_HTML5);
10echo "Decoded: " . $decoded . "\n";
11?>
Java
1public class HtmlEscapeUtil {
2 // 5-character core HTML escape
3 public static String escapeHtml(String input) {
4 if (input == null) return "";
5 return input.replace("&", "&amp;")
6 .replace("<", "&lt;")
7 .replace(">", "&gt;")
8 .replace(""", "&quot;")
9 .replace("'", "&#39;");
10 }
11 
12 public static void main(String[] args) {
13 String text = "<script>alert('Hello & "World"');</script>";
14 String escaped = escapeHtml(text);
15 System.out.println("Escaped: " + escaped);
16 }
17}
C# / .NET
1using System;
2using System.Net;
3 
4class Program {
5 static void Main() {
6 string raw = "<div class="user">Admin & User 'A'</div>";
7 
8 // 1. WebUtility.HtmlEncode
9 string encoded = WebUtility.HtmlEncode(raw);
10 Console.WriteLine($"Encoded: {encoded}");
11 
12 // 2. WebUtility.HtmlDecode
13 string decoded = WebUtility.HtmlDecode(encoded);
14 Console.WriteLine($"Decoded: {decoded}");
15 }
16}
Go
1package main
2 
3import (
4 "fmt"
5 "html"
6)
7 
8func main() {
9 raw := "<script>alert('Hello & "World"');</script>"
10 
11 // 1. EscapeString
12 encoded := html.EscapeString(raw)
13 fmt.Println("Encoded:", encoded)
14 
15 // 2. UnescapeString
16 decoded := html.UnescapeString(encoded)
17 fmt.Println("Decoded:", decoded)
18}

Client-Side Local Processing FAQ

Q.How does HTML Entity encoding differ from URL Percent-Encoding?

HTML entity encoding replaces reserved markup characters with &amp;, &lt;, &gt; to prevent tag collisions and XSS vulnerabilities in web documents. URL percent-encoding translates characters into %20, %26, %3F to safely transmit parameters across HTTP network requests.

Q.Why is &#39; preferred over &apos; for single quotes?

&apos; was introduced in XML and HTML5, but legacy Internet Explorer (IE8 and earlier) did not support it. Decimal &#39; and hex &#x27; are universally recognized across all legacy and modern browsers.

Q.Do all Unicode and non-English characters need entity encoding?

No. Modern web applications declare <meta charset="UTF-8">, rendering Unicode characters natively without issues. However, entity encoding is useful for legacy email clients or ASCII-only environments.

Q.Do modern frameworks like React and Vue require manual entity encoding?

Standard JSX bindings (<div>{userInput}</div>) and Vue templates (<div>{{ userInput }}</div>) automatically escape text nodes. Manual encoding is only necessary when injecting raw HTML via dangerouslySetInnerHTML or v-html.

Q.What is Double Escaping and how can it be avoided?

Double escaping occurs when an already-escaped string (&lt;div&gt;) is escaped a second time, converting the ampersand into &amp;lt;div&amp;gt;. Ensure sanitization occurs exactly once before DOM rendering.

Q.Is decoding HTML entities safe from executing malicious scripts?

Yes. This tool's decoding engine parses text using virtual text nodes (DOM Text Content), so no JavaScript executes during decoding.

Q.Is my HTML input sent to any remote server?

No. All encoding and decoding run locally in your browser memory via client-side JavaScript.

Q.What is the difference between Decimal and Hexadecimal entities?

Both reference Unicode code points. Decimal uses &# followed by base-10 numbers (&#60;), while Hex uses &#x followed by base-16 hex values (&#x3C;). Both render identically in web browsers.