HTML Entity Converter

Convert special characters to HTML entities or decode them back to plain text.

HTML entities are special character sequences that represent reserved or invisible characters in HTML documents. This free online HTML entity encoder and decoder converts between raw characters and their entity equivalents instantly. Encode text to prevent XSS attacks and rendering issues, or decode entities to read the original content. All processing runs in your browser with zero server communication.

Your data stays in your browser
Was this tool useful?
Tutorial

How to use

1
1

Usage Step

Convert special characters to HTML entities or decode them back to plain text.

Guide

Complete Guide to HTML Entities

What are HTML Entities?

HTML entities are special strings that begin with an ampersand (&) and end with a semicolon (;). They represent characters that are either reserved in HTML (like < > & and quotes) or not easily typed on a keyboard (like em dashes, copyright symbols, or accented letters). For example, &lt; represents the less-than sign (<) and &amp; represents the ampersand itself. The HTML specification defines both named entities (like &copy;) and numeric entities (like &#169; or &#x00A9;) for hundreds of Unicode characters.

Why HTML Entity Encoding Matters

Encoding special characters as HTML entities is essential for two reasons. First, it prevents the browser from misinterpreting content as markup — a bare < in text would be read as a tag opening. Second, and critically, it defends against Cross-Site Scripting (XSS) attacks where malicious scripts are injected through user input. By encoding characters like < > and quotes before inserting user data into HTML, you neutralize potential attack vectors. Every web framework includes HTML escaping for this reason.

Named vs Numeric Entities

Named entities use human-readable codes like &amp; &lt; &gt; &quot; and &apos;. Numeric entities use decimal (&#60;) or hexadecimal (&#x3C;) Unicode code points. Named entities are easier to read in source code, but only a subset of Unicode characters have named entities. Numeric entities can represent any Unicode character, making them more versatile for special symbols, mathematical notation, and international characters.

Best Practices

Always encode the five critical characters in user-generated content: < > & single quote and double quote. Use your framework or library built-in escaping functions rather than manual replacement to avoid missing edge cases. In modern HTML5, only &amp; &lt; &gt; &quot; and &apos; are strictly required entities — other Unicode characters can be included directly if the document uses UTF-8 encoding.

Examples

Worked Examples

Example: Encoding User Input for HTML Display

Given: user-submitted text containing <script>alert(1)</script>

1

Step 1: Identify dangerous characters: < > and quotes.

2

Step 2: Replace < with &lt; and > with &gt; throughout the string.

3

Step 3: Replace any quotes with &quot; or &#39; to prevent attribute escaping.

Result: &lt;script&gt;alert(1)&lt;/script&gt; (safely rendered as text)

Example: Decoding an HTML Email Template

Given: template string Tom &amp; Jerry&#39;s &lt;Adventures&gt;

1

Step 1: Identify all entity patterns: &amp; &#39; &lt; &gt;.

2

Step 2: Replace each entity with its character: &amp; becomes &, &#39; becomes single-quote, etc.

3

Step 3: Verify the decoded string reads naturally.

Result: Tom & Jerry's <Adventures>

Use Cases

Use cases

Prevent XSS Attacks

Encode all user-generated content before inserting it into your HTML to neutralize Cross-Site Scripting (XSS) vectors. Characters like < > and quotes must be converted to their entity equivalents so browsers render them as text, not executable markup. This is the single most important defense against injection attacks.

Display Code Snippets

When showing HTML, XML, or JSX code examples on a web page, all angle brackets and ampersands must be entity-encoded so the browser displays them instead of interpreting them as tags. This tool lets you paste raw code and instantly get the entity-encoded version ready for embedding in blog posts or documentation.

Email Template Development

HTML email clients have inconsistent entity support, so testing encoded content is essential. Use this tool to encode special characters like copyright symbols, em dashes, and curly quotes into their numeric entity forms which have the widest email client compatibility across Outlook, Gmail, and Apple Mail.

Decode Legacy Content

Older CMS platforms and databases sometimes store content with excessive entity encoding, making it hard to read or migrate. Paste the over-encoded text into the decoder to recover the original characters and clean up your content for migration to modern UTF-8 systems.

Frequently Asked Questions

?What are HTML entities and why are they needed?

HTML entities are special character sequences like &lt; and &amp; that represent reserved characters in HTML. They prevent browsers from misinterpreting content as markup and defend against XSS injection attacks.

?How do I encode text to HTML entities?

Paste your text into the input field and click Encode. All special characters are converted to their HTML entity equivalents instantly. Copy the result with one click.

?What is the difference between named and numeric entities?

Named entities like &amp; are human-readable but limited. Numeric entities like &#38; use Unicode code points and can represent any character. Both are decoded identically by browsers.

?Which characters must be encoded in HTML?

The five critical characters are: < (less-than), > (greater-than), & (ampersand), and both single and double quotes. These prevent XSS attacks and rendering errors.

?How do HTML entities prevent XSS attacks?

By converting < and > to &lt; and &gt;, injected script tags are rendered as harmless text instead of being executed by the browser. This is a fundamental web security practice.

?Is this HTML entity tool free?

Yes, completely free with no registration, no limits, and no ads.

?Is my data private?

All encoding and decoding runs locally in your browser. No data is sent to any server. Your content remains completely private.

?Can I encode Unicode characters as HTML entities?

Yes. Any Unicode character can be represented as a numeric HTML entity using its code point, like &#169; for the copyright symbol or &#x2764; for a heart.

Help us improve

How do you like this tool?

Every tool on Kitmul is built from real user requests. Your rating and suggestions help us fix bugs, add missing features and build the tools you actually need.

Rate this tool

Tap a star to tell us how useful this tool was for you.

Suggest an improvement or report a bug

Missing a feature? Found a bug? Have an idea? Tell us and we'll look into it.

Related Tools

Recommended Reading

Recommended Books on HTML & Web Development

As an Amazon Associate we earn from qualifying purchases.

Boost Your Capabilities

Professional Products to Boost Your Development Setup

As an Amazon Associate we earn from qualifying purchases.

Newsletter

Get Free Productivity Tips & New Tools First

Join makers and developers who care about privacy. Every issue: new tool drops, productivity hacks, and insider updates — no spam, ever.

Priority access to new tools
Unsubscribe anytime, no questions asked