HTML Entity Encoder / Decoder

Encode and decode HTML entities for safe display in web pages

Encoding Options

All encoding and decoding is done locally in your browser.

About HTML Entity Encoder / Decoder

This free online HTML entity encoder and decoder helps you convert special characters to HTML entities and vice versa. HTML entities are used to display reserved characters in HTML that would otherwise be interpreted as HTML code.

For example, the less-than sign (<) must be encoded as &lt; to display correctly in HTML. This tool makes encoding and decoding HTML entities quick and easy.

All text processing is done locally in your browser - your data never leaves your device.

How to Use

  1. Paste or type your text in the input area
  2. Choose encoding options:
    • Named Entities: Convert to readable entity names like &lt;, &gt;, &amp;
    • Numeric Entities: Convert to decimal numbers like &#60;, &#62;, &#38;
    • Hexadecimal Entities: Convert to hex numbers like &#x3C;, &#x3E;, &#x26;
  3. Click Encode to convert special characters to HTML entities
  4. Click Decode to convert HTML entities back to regular characters
  5. Use Swap to exchange input and output text
  6. Copy the result or download as a text file

Features

  • Encode to HTML Entities: Convert special characters to safe HTML entities
  • Decode HTML Entities: Convert HTML entities back to regular characters
  • Multiple Entity Types: Named, numeric (decimal), and hexadecimal entities
  • Flexible Encoding: Encode all characters or special characters only
  • Swap Input/Output: Quickly swap text between input and output
  • Character Statistics: See character counts and entity counts
  • Copy to Clipboard: One-click copying
  • Download as File: Save results as .txt or .html file
  • Real-time Processing: Instant encoding and decoding

Privacy & Security

Your privacy is important. This tool processes all text entirely in your browser.

  • No data is sent to any server
  • No logging or tracking of your text content
  • Works completely offline after initial page load
  • Safe for sensitive HTML code and content

Common Use Cases

  • Web Development: Safely display user input or code snippets in HTML
  • Email Templates: Encode special characters for HTML emails
  • XML/RSS Feeds: Encode content for XML documents
  • Content Management: Prepare text for database storage or display
  • Code Documentation: Display HTML code examples without execution
  • SEO & Meta Tags: Encode special characters in meta descriptions
  • XSS Prevention: Sanitize user input to prevent cross-site scripting attacks
  • Data Migration: Convert between different encoding formats

Key Terms & Concepts

HTML Entity

An HTML entity is a piece of text (string) that begins with an ampersand (&) and ends with a semicolon (;). Entities are used to display reserved characters that would otherwise be interpreted as HTML code, and characters that don't appear readily on your keyboard.

Named Entities

Named entities use descriptive names that are easy to remember. For example: &lt; for less-than (<), &gt; for greater-than (>), &amp; for ampersand (&), &quot; for quote ("), and &nbsp; for non-breaking space.

Numeric Entities

Numeric entities use decimal numbers to represent characters based on their Unicode code point. For example: &#60; for <, &#62; for >, &#38; for &. Numeric entities work for any Unicode character.

Hexadecimal Entities

Hexadecimal entities are similar to numeric entities but use hexadecimal (base-16) numbers instead of decimal. For example: &#x3C; for <, &#x3E; for >, &#x26; for &. Many developers prefer hex entities as they match Unicode notation.

Character Encoding

Character encoding is the process of converting characters into a format that can be safely stored or transmitted. HTML entity encoding is one method of character encoding specifically designed for HTML and XML documents.

Reserved Characters

Reserved characters in HTML are characters that have special meaning and cannot be used directly in content. These include: < (less than), > (greater than), & (ampersand), " (quote), and ' (apostrophe). These must be encoded as HTML entities.

Examples

Example 1: Encoding Special Characters

Input:

<div class="container">Hello & Welcome!</div>

Output (Named Entities):

&lt;div class=&quot;container&quot;&gt;Hello &amp; Welcome!&lt;/div&gt;

Example 2: Decoding HTML Entities

Input:

Price: &pound;99.99 &ndash; Order now &rarr;

Output:

Price: £99.99 – Order now →

Example 3: Numeric vs Named Entities

Original: <

Named Entity: &lt;

Numeric Entity: &#60;

Hex Entity: &#x3C;

All three formats represent the same character and will display identically in a browser.

Important Notes

Browser Support: HTML entities are supported by all web browsers. Named entities are more readable but may not be supported for all Unicode characters. Numeric and hexadecimal entities work for any character.
Encoding Requirement: Not all characters need to be encoded. Only reserved characters (<, >, &, ", ') and special Unicode characters that may not display correctly need encoding.
URL Encoding vs HTML Encoding: HTML entity encoding is different from URL encoding. HTML entities are used in HTML content, while URL encoding is used in web addresses. Don't confuse the two.
Performance: For large amounts of text, encoding every character can significantly increase file size. Use "encode special characters only" for better performance.
Double Encoding: Be careful not to encode text that's already encoded. For example, encoding &lt; again would result in &amp;lt;, which displays as &lt; instead of <.
Case Sensitivity: Named entities are case-sensitive. &Nbsp; is not the same as &nbsp;. Always use the correct case.
Advertisement