UltraConvert
Encoders

HTML Entities Encoder & Decoder

Escape special HTML characters so they're safe to embed in web pages, or reverse the process to decode entity references back to readable text. Optional numeric entity mode encodes every non-ASCII character to ensure maximum compatibility with legacy systems, email clients, and specific character encodings.

What does this tool do?

The HTML Entities tool provides bidirectional conversion between special characters and their HTML entity representations. Encoding converts characters like < > & " to their entity forms (&lt; &gt; &amp; &quot;) so they display correctly in HTML rather than being interpreted as markup. Decoding reverses entity references back to the actual characters. The optional numeric entity mode (&#[decimal];) encodes all non-ASCII characters, useful for systems that don't properly handle UTF-8.

How it works

Encoding uses a character mapping table for the five essential XML/HTML entities and their named forms: & → &amp;, < → &lt;, > → &gt;, " → &quot;, ' → &apos;. When numeric mode is enabled, characters outside the ASCII printable range are converted to &#NNNN; decimal entity references. Decoding uses regex to find entity patterns (named: &name; numeric: &#NN; or &#xNN;) and maps them back to Unicode characters via HTML entity tables and parseInt for numeric values. All processing is done client-side with no server interaction.

Features

How to use

  1. 1

    Paste your input

    Enter plain text to encode, or HTML-escaped text with entities to decode. The tool auto-detects content type or you can switch modes manually.

  2. 2

    Select encode or decode

    Choose Encode to make text safe for HTML, or Decode to convert entities back to readable characters.

  3. 3

    Toggle numeric entities (encode)

    Enable numeric entities to encode all non-ASCII as &#NNNN; — useful for email or legacy systems that may mangle UTF-8.

  4. 4

    Copy result

    Grab the encoded text for your HTML source, or the decoded text for normal reading and editing.

Common use cases

Embed code in HTML

Encode < and > in code examples so they display correctly rather than being parsed as HTML tags by browsers.

Email content preparation

Use numeric entities for email HTML to maximize compatibility with various email clients that handle character encodings inconsistently.

Debugging scraped content

Decode entity references in web-scraped content to see the actual text, or encode user input before inserting into HTML templates.

Legacy system compatibility

Encode to numeric entities for systems that don't properly support UTF-8, ensuring characters display correctly regardless of encoding settings.

Tips & best practices

Frequently asked questions

Why encode non-ASCII characters?
Numeric entity mode (&#NNNN;) is useful for emails or older systems that mangle UTF-8. For modern web pages with charset=utf-8 you don't need it — the five named entities for < > & " ' are sufficient.
Are all named entities supported?
On decode, all standard HTML5 entity names are supported (&copy; &reg; &euro; etc.). Lesser-known entities pass through unchanged if unrecognized. On encode, only the five essential XML entities are produced by default.
What's the difference between decimal and hex entities?
Decimal: &#169; (copyright). Hexadecimal: &#xA9; or &#xa9; (same character). Both represent the same Unicode codepoint, just different number bases. This tool supports both on decode; produces decimal on encode.
Does this protect against XSS?
Encoding < > & " ' prevents HTML injection, but is not complete XSS protection. Always use proper HTML sanitization libraries for user content, and context-appropriate encoding (HTML, JavaScript, CSS, URL encoding each have different requirements).

Related tools