UFOZoo

HTML Entity Encoder — Escape Special Characters Online

Encode special characters to HTML entities or decode them back. Prevents XSS attacks and broken markup. Supports named, decimal, and hex references.

Features

  • Encode or decode HTML entities in real time
  • Supports named entities (&), decimal (&), and hex (&) references
  • Encode all non-ASCII option for international content compatibility
  • Instant results as you type, no button to press
  • Drag-and-drop files, one-click copy, and save as .txt
  • Works entirely in your browser — no data uploaded
  • Encode all five XML-sensitive characters (<, >, &, ", ') in one pass
  • Decode entity-encoded strings back to their original characters automatically
  • Character-level and byte-level length counters for content size management
  • Preserve existing entities during encoding to avoid double-encoding issues

How to Use

  1. 1Paste your text into the input area. Toggle between Encode and Decode.
  2. 2Enable Encode all non-ASCII to convert non-ASCII chars (é, 中文, 🚀) to numeric entities.
  3. 3Results update instantly. Use Copy or Save to save.
  4. 4Encode a code snippet before embedding it in a blog post — paste your code and copy the encoded version to prevent HTML rendering issues.
  5. 5Decode RSS feed content or HTML email templates that use numeric entities — paste the encoded text and switch to Decode mode to see the original.
  6. 6Use named entity output for better readability when sharing encoded content with other developers.
  7. 7Use decimal or hex numeric entities for universal support of any Unicode character, especially when named entities don't exist.
  8. 8Enable Encode all non-ASCII before publishing internationalized content to legacy CMS systems that lack UTF-8 support.
  9. 9Batch-process multiple snippets by opening a file, encoding all content at once, and saving the results.
  10. 10Verify your encoded output by pasting it into a browser's developer tools console to confirm it renders correctly.

Frequently Asked Questions

What is HTML entity encoding?

HTML entity encoding converts special characters that have meaning in HTML (<, >, &, ", ') into safe entity equivalents like &lt;, &gt;, &amp;. This prevents the browser from interpreting them as markup, which is essential for displaying code snippets and preventing XSS attacks.

What's the difference between named, decimal, and hex entities?

Named entities use descriptive names like &amp; or &lt;. Decimal numeric entities use &#38; (the decimal code point). Hex numeric entities use &#x26; (the hex code point). Named entities are more readable, but numeric entities work for any Unicode character. All are valid in HTML5.

What does Encode all non-ASCII do?

When enabled, all non-ASCII characters (including emojis, Chinese, accented letters, and other Unicode) are converted to numeric entities like &#233;. This is useful for older systems that may not handle UTF-8 correctly, or for ensuring maximum compatibility across different character encodings.

Is my data sent to a server?

No. All processing happens entirely in your browser using JavaScript. Your data never leaves your device, is never transmitted over the network, and is never stored anywhere.

When should I use HTML entity encoding?

Use HTML entity encoding when displaying user-generated content in web pages (XSS prevention), embedding code snippets in blog posts or documentation, or inserting special characters into HTML attributes. Modern frameworks like React auto-escape by default, but manual encoding is needed for raw innerHTML, CMS exports, and email templates.

Does HTML entity encoding prevent XSS attacks?

Yes, encoding user input as HTML entities is a primary defense against XSS (Cross-Site Scripting) attacks. By converting < to &lt; and > to &gt;, browsers won't interpret injected HTML tags or scripts. Always encode user-generated content before rendering it in HTML pages.

What characters are converted when encoding HTML entities?

The five essential characters are: & (ampersand → &amp;), < (less-than → &lt;), > (greater-than → &gt;), " (double quote → &quot;), and ' (single quote → &#39;). The Encode all non-ASCII option additionally converts any character outside the ASCII range to numeric entities.

Can I encode text with mixed content (HTML + plain text)?

Yes. The tool treats all input as plain text for encoding — it escapes characters without trying to parse HTML. This means existing entities like &amp; will be double-encoded (&amp;amp;) when encoding. For decode mode, existing entities are properly decoded back to characters.

How do I avoid double-encoding?

Double-encoding happens when you encode text that already contains entities (e.g., encoding &amp; again produces &amp;amp;). To avoid this, use Decode mode first to restore entities to their original characters, then Encode. The tool preserves existing entities during encoding.

What's the difference between &amp; and &#38;?

Both represent the ampersand character. &amp; is a named entity — more readable and descriptive. &#38; is a decimal numeric entity using the character's Unicode code point (38 = 0x26). &#x26; is the hex equivalent. All are valid HTML5 and browsers render them identically.

When should I use the Encode all non-ASCII option?

Use this when targeting email clients that use legacy character encodings like ISO-8859-1, or when publishing content to CMS platforms known to mishandle UTF-8. It converts emojis, Chinese, accented letters, and other Unicode to numeric entities, ensuring faithful rendering everywhere.

Related Tools