Command Palette

Search for a command to run...

HT

HTML Entity Encoder/Decoder

Encode and decode HTML entities - named (&), decimal (&), and hex (&) forms, with XSS-safe special-character escaping

0 characters
0 characters
Output will appear here...
Category:encoding
Mode:Offline
Version:1.0.0
Access:Free

What is HTML Entity Encoder/Decoder?

HTML Entity Encoder/Decoder interface on Toolz.dev - Encode and decode HTML entities - named (&), decimal (&), and hex (&) forms, with XSS-safe special-character escaping

HTML Entity Encoder/Decoder converts characters that have special meaning in HTML into safe entity references, and turns entities from any source back into readable text. In HTML, < starts a tag and & starts an entity - so if user-generated content containing <script> lands in your markup unescaped, the browser executes it. Escaping those characters as &lt;script&gt; is the canonical defense against reflected and stored XSS, and this tool performs exactly that transformation using OWASP's recommended minimum set: & < > " and the single quote.

The tool supports three encoding strategies because different contexts need different output. Named mode uses a built-in map of over 100 memorable entities - &copy; for ©, &eacute; for é, &mdash; for - , &hellip; for … - with an automatic numeric fallback (&#NNNN;) for any character without a common name, including emoji. Numeric mode encodes everything as decimal character references, which is what you want for XML or RSS feeds where only five named entities (&amp; &lt; &gt; &quot; &apos;) are defined and &nbsp; would break the parser. Special-only mode escapes just the five XSS-critical characters, leaving accented text and typography readable in your source - the mode most template engines use by default.

The decoder is equally thorough: it handles named entities, decimal references like &#233;, and hexadecimal references like &#xE9; - all three forms you will find mixed together in scraped pages, CMS exports, and email HTML. Everything is implemented in pure TypeScript with no DOM tricks (no hidden textarea hack, no document.createElement), which means results are deterministic and the same logic runs identically in your browser, the desktop app, and on the server. Your content never leaves your machine - 100% client-side processing, safe for proprietary copy and user data alike.

How to use HTML Entity Encoder/Decoder?

1

Paste your text or HTML

Enter raw text you need to make HTML-safe (user input, marketing copy with © and ™, code snippets destined for a <pre> block), or paste entity-riddled HTML like &lt;div class=&quot;card&quot;&gt; that you want to read as plain text.

2

Choose an encoding mode

Named for human-readable output (&copy;, &eacute;), Numeric for XML/RSS-safe decimal references (&#169;, &#233;), or Special-only to escape just & < > " ' - the minimum required to prevent XSS while keeping the rest of the text readable.

3

Encode or decode

Click Encode to convert characters to entities, or Decode to resolve named, decimal (&#123;), and hex (&#x1F;) references back to characters. The live character count shows how much the entity expansion grew your string.

4

Copy or swap

Copy the result to your clipboard, or hit swap to feed the output back as input - useful for peeling apart double-encoded strings like &amp;amp;lt; that went through two escaping layers.

Key Features

100+ named entities

Built-in map covering XSS characters, typography (&mdash; &hellip; smart quotes), currency (&euro; &pound;), math symbols, Greek letters, and the full Latin-1 accented alphabet

Three encoding modes

Named for readability, numeric for XML/RSS compatibility, special-only for minimal XSS-safe escaping - pick per context instead of one-size-fits-all

Decodes all three entity forms

Named (&amp;), decimal (&#38;), and hexadecimal (&#x26;) references are all recognized, even when mixed in the same document

Pure TypeScript, no DOM

No hidden-element browser hacks - deterministic logic that behaves identically in web, desktop, and server environments

Frequently Asked Questions

At minimum: & < > " and the single quote - that is the OWASP-recommended set for HTML body and attribute contexts, and exactly what the special-only mode encodes. The ampersand must be escaped first (or handled atomically, as this tool does) or you will corrupt already-encoded entities. Note that entity encoding protects HTML contexts only; injecting user data into <script> blocks, URLs, or CSS requires different, context-specific escaping.

Comments

0 comments

0/2000 characters

No comments yet. Be the first to share your thoughts!

html entitieshtml encoderhtml decoderhtml escapehtml unescapenamed entitiesnumeric character referencexss escapingspecial charactersampersand encoding