HTML Entity Encoder/Decoder

Encode special characters to HTML entities or decode HTML entities back to characters. Supports 200+ named entities, numeric decimal and hexadecimal entities, with multiple encoding modes. All processing happens client-side -- your data never leaves your browser.

Mode:

Live Preview (how the output renders in HTML)

Preview will appear here

HTML Character Reference Table

How It Works

Instant Encoding

Paste any text and instantly convert special characters to their HTML entity equivalents. Choose between minimal, full, or numeric-only encoding modes depending on your needs.

🔍

Smart Decoding

Decode HTML entities back to readable characters. Supports all 200+ named entities like © and —, decimal numeric entities (©), and hexadecimal entities (©).

👁

Live Preview

See exactly how your encoded output would render in a browser. The live preview panel shows the visual result in real time so you can verify correctness before using the output.

📚

Reference Table

Browse and search a comprehensive table of 200+ HTML character entities. Find the named, decimal, and hex codes for any character with instant search and filtering.

Understanding HTML Entities

HTML entities are special sequences of characters used to represent symbols that have reserved meaning in HTML or that cannot be easily typed on a standard keyboard. Every HTML entity starts with an ampersand (&) and ends with a semicolon (;). They are essential for writing correct, secure, and cross-browser-compatible HTML documents.

Types of HTML Entities

There are three ways to represent a character as an HTML entity:

Why Encode HTML Entities?

There are two critical reasons to encode HTML entities:

Encoding Modes Explained

Common Use Cases

Frequently Asked Questions

What are HTML entities?
HTML entities are special codes used to represent characters that have special meaning in HTML or cannot be easily typed on a keyboard. They begin with an ampersand (&) and end with a semicolon (;). For example, &lt; represents the less-than sign (<), &amp; represents the ampersand (&), and &copy; represents the copyright symbol. HTML entities ensure that browsers render characters correctly instead of interpreting them as HTML markup. Without entities, characters like < and > would be treated as tag delimiters, breaking your page layout or creating security vulnerabilities.
Which characters must be encoded in HTML?
At minimum, five characters must be encoded when they appear in HTML content: the ampersand (&) as &amp;, less-than (<) as &lt;, greater-than (>) as &gt;, double quote (") as &quot; (required inside attribute values), and single quote/apostrophe (') as &#39; or &apos; (required inside single-quoted attributes). Beyond these five, encoding non-ASCII characters (accented letters, symbols, emoji) is recommended for maximum compatibility, especially if your document encoding is uncertain or you are working with systems that only support ASCII.
What is the difference between named and numeric entities?
Named entities use a human-readable name between & and ;, such as &amp; (ampersand), &copy; (copyright), or &mdash; (em dash). They are easier to read and remember but only about 250 characters have named entities. Numeric entities use the Unicode code point in decimal (&#169;) or hexadecimal (&#xA9;) format and can represent any of the 140,000+ Unicode characters. Both forms are valid HTML and render identically in browsers. Use named entities for readability in hand-written HTML, and numeric entities when you need to represent characters that do not have a named equivalent.
How does HTML entity encoding prevent XSS attacks?
Cross-Site Scripting (XSS) attacks work by injecting malicious HTML or JavaScript into a web page through user-controlled input like form fields, URL parameters, or comments. For example, an attacker might submit <script>alert('hack')</script> as their "name." Without encoding, the browser would execute this as a real script. By encoding the input, the < becomes &lt; and the > becomes &gt;, so the browser displays the text literally instead of executing it as code. This is why output encoding (also called output escaping) is one of the primary defenses against XSS recommended by OWASP. Always encode user-supplied data before inserting it into HTML contexts.
When should I use numeric vs. named entities?
Use named entities (&copy;, &mdash;) when writing HTML by hand, as they are more readable and self-documenting. Use numeric entities (&#169;, &#x2014;) when you need to represent characters that do not have a named entity, when working with systems that may not recognize all named entities, or when you want a consistent encoding format for programmatic processing. Some older email clients and XML parsers only recognize the five basic named entities (&amp;, &lt;, &gt;, &quot;, &apos;) and require numeric entities for everything else. In XML, only those five named entities are predefined -- all others must be numeric.
Is it safe to use this tool with sensitive data?
Yes. This tool runs entirely in your browser using client-side JavaScript. No data is sent to any server, stored in any database, or logged anywhere. All encoding and decoding happens locally on your device using standard character mapping. You can verify this by checking the browser's Network tab in Developer Tools -- no requests are made when you use the tool. This makes it safe to use with any text, including sensitive content, API responses, or production data.
What encoding mode should I choose?
Minimal is the best default choice for most web development. It only encodes the five characters that have special meaning in HTML (&, <, >, ", '), producing clean, readable output. Full mode is useful when your output will be consumed by systems with limited character set support, email templates, or when you want to ensure every non-ASCII character (accented letters, symbols, currency signs) is explicitly encoded. Numeric mode encodes everything as decimal numeric entities and is ideal for XML documents, maximum cross-platform compatibility, or when you need a consistent encoding format that does not depend on named entity support.

Explore More Developer Tools

Check out our other free developer tools. Format JSON, decode JWTs, parse AWS ARNs, and more -- all from your browser with no sign-up required.

JSON Formatter →