HTML Entity Encoder

Convert special characters to HTML entities and back. Encode and decode HTML entities instantly in your browser.

🔄

Bidirectional

Encode plain text to HTML entities or decode entities back to readable text.

Real-time Mode

Enable real-time conversion to see changes as you type.

🔒

100% Private

All encoding happens in your browser. No data sent to servers.

Understanding HTML Entities

HTML entities are special codes used to display reserved characters in HTML. Characters like <, >, and & have special meaning in HTML, so they must be encoded as entities to display correctly. This prevents browsers from interpreting them as HTML code and ensures your content displays exactly as intended.

Common HTML Entities

  • &lt; - Less than sign (<)
  • &gt; - Greater than sign (>)
  • &amp; - Ampersand (&)
  • &quot; - Double quotation mark (")
  • &#39; or &apos; - Single quotation mark (')
  • &nbsp; - Non-breaking space

When to Use HTML Entities

Use HTML entities when displaying code snippets on web pages (preventing code from executing), showing special characters that aren't on standard keyboards, preventing XSS (Cross-Site Scripting) attacks by encoding user input, ensuring compatibility across different browsers and character sets, and displaying mathematical symbols, currency signs, or copyright symbols.

Entity Types

  • Named entities: Human-readable names like &lt; for <
  • Numeric entities: Decimal format like &#60; for <
  • Hex entities: Hexadecimal format like &#x3C; for <

FAQ

What are HTML entities?

HTML entities are special character sequences that start with an ampersand (&) and end with a semicolon (;). They're used to display reserved characters, special symbols, or characters not available on standard keyboards in HTML documents.

Why do I need to encode HTML entities?

Encoding is necessary to prevent browsers from interpreting special characters as HTML code. For example, if you want to display "<html>" as text, you must encode it as "&lt;html&gt;" or the browser will treat it as an actual HTML tag. It's also crucial for security to prevent XSS attacks.

What's the difference between &quot; and &#39;?

&quot; represents a double quotation mark ("), while &#39; represents a single quotation mark ('). Both are commonly used in HTML attributes to avoid conflicts with the quote marks that define attribute values.

Can I use this tool for preventing XSS attacks?

While encoding user input is an important part of XSS prevention, it should be part of a comprehensive security strategy. Always validate and sanitize user input on the server side, use Content Security Policy headers, and follow security best practices for your specific framework.

Do I need to encode all special characters?

Not all special characters require encoding. You must encode <, >, &, and quotes in HTML attributes. Other characters like copyright (©) or trademark (™) symbols can be typed directly with UTF-8 encoding, though entities like &copy; and &trade; work too.