Ttooleras
🏷️

HTML Entity Encoder/Decoder

Encoders & Decoders

Encode special characters to HTML entities (&, <, ", ©) or decode entities back to their literal characters.. Free, private — all processing in your browser.

HTML Entity Reference — click to insert
Advertisement

Convert text to HTML entities and back. Paste code or text to encode the characters that would otherwise break your markup — < > & and quotes become < > & — or paste entity-encoded HTML to decode it back to readable characters. It processes as you type, with a reference table of common entities you can click to insert.

Why this matters: if you want to display literal HTML on a page (a code example, a snippet in a tutorial), you can't just drop < and > into the markup — the browser would try to render them as tags. Encoding them as entities makes the browser show the characters instead of interpreting them. Encoding is also the baseline defense against injecting untrusted text into HTML.

Encode has two modes: escape only the special characters (the common case, keeps text readable), or encode every character as a numeric entity (useful for obfuscation or forcing a specific representation). Decode handles named, numeric, and hex entities alike.

How to use the HTML Entity Encoder/Decoder

  1. 1

    Pick direction

    Encode text to entities, or decode entities back to text.

  2. 2

    Paste your content

    Drop the text or entity-laden content into the input.

  3. 3

    Set encoding strategy

    For encoding: choose minimal (essentials only), standard, or maximum (all non-ASCII).

  4. 4

    Review the preview

    See how the encoded text renders in a browser alongside the raw entity form.

  5. 5

    Copy

    One-click copy the result for pasting into your code or document.

HTML Entity Encoder/Decoder — examples

Essential escaping

Minimal encoding of HTML-dangerous characters.

Input
<p>Hello & welcome</p>
Output
&lt;p&gt;Hello &amp; welcome&lt;/p&gt;

Copyright symbol

Encoding a non-ASCII character.

Input
© 2026 Tooleras
Output
&copy; 2026 Tooleras
or numeric: &#169; 2026 Tooleras

Decoding

Entities back to literal characters.

Input
Tom &amp; Jerry said &quot;hi&quot;
Output
Tom & Jerry said "hi"

Mixed forms

Named and numeric entities handled together.

Input
&copy; by Don&#39;t &#x00A9; 2024
Output
© by Don't © 2024
(three entity forms all decoded)

XSS prevention

Encoding user input safely for HTML.

Input
<script>alert("XSS")</script>
Output
&lt;script&gt;alert(&quot;XSS&quot;)&lt;/script&gt;
(safe to embed in HTML)

Features at a glance

Two-way conversion

Encode text to entities or decode entities back to text in one tool.

Named and numeric forms

Handles &copy;, &#169;, and &#x00A9; — all three forms of the same character.

Encoding strategies

Minimal (just & < >), standard, or maximum (all non-ASCII) depending on your safety needs.

250+ named entities

Full HTML5 named entity list including Greek letters, arrows, and typographic marks.

XSS-safe encoding

Minimal mode matches the escaping strategies of React, Angular, and major templating engines.

Preview

See how the encoded text will render in a browser before using it.

Copy-ready output

One-click copy the encoded or decoded result for pasting into code or content.

Client-side only

Input text never leaves your browser — safe for sensitive content.

When to use the HTML Entity Encoder/Decoder

Web development

  • User input sanitization: Encode text from user input before embedding in HTML to prevent XSS attacks.
  • CMS content embedding: Convert special characters in CMS content to entities so they display literally rather than being parsed as markup.
  • Email HTML: Prepare content for HTML email templates where some email clients strip non-entity special characters.

Content processing

  • Decode scraped content: Convert HTML-encoded text from scraped pages back to readable form.
  • Email archive extraction: Turn entity-laden email archives into plain readable text.
  • Documentation cleanup: Decode raw HTML source pulled from exports to more readable form for editing.

Data interchange

  • XML vs HTML: Convert between HTML and XML-safe forms (some entities differ).
  • JSON embedding: Ensure special characters in JSON strings are entity-escaped where needed.
  • API payload cleaning: Strip or encode special characters in text fields before API submission.

Under the hood

Special-character encoding replaces the HTML-significant characters: & becomes &amp;amp;, < becomes &amp;lt;, > becomes &amp;gt;, double quote becomes &amp;quot;, single quote becomes &amp;#39;, and forward slash becomes &amp;#x2F; (slash escaping is a defensive practice that helps prevent breaking out of attribute contexts). The "all characters" mode instead emits every character as a numeric entity in the &amp;#N; form, where N is the Unicode code point.

Decoding uses the browser's own HTML parser: the input is assigned to a textarea's innerHTML and read back as text, so it correctly resolves the full range of named entities (&amp;copy;, &amp;mdash;, &amp;nbsp; and hundreds more), plus decimal (&amp;#169;) and hexadecimal (&amp;#xA9;) numeric references — exactly as a browser would. That makes decoding robust across any valid entity, not just a hardcoded list.

Everything runs locally in your browser; nothing you paste is uploaded.

Pitfalls and fixes

Don't double-encode

If your framework or template already auto-escapes HTML (React, Vue, most server templates do), encoding again here produces &amp;amp;lt; instead of &lt;. Encode manually only for raw output that isn't already escaped.

Entity encoding isn't full XSS protection

Escaping for HTML body context is the baseline, but attributes, URLs, JavaScript, and CSS each need their own escaping. Encoding HTML entities alone doesn't make untrusted input safe in every context.

'All characters' mode bloats the output

Encoding every character as a numeric entity multiplies the size several times over. It's for obfuscation or forcing a representation, not for normal HTML — use 'special chars only' for real markup.

Encoding is context-specific

The right escaping depends on where the text goes. This encodes for HTML content; putting the result into a JavaScript string or a URL needs different escaping (JS string escaping or URL encoding).

Decoding runs the browser's parser

Because decode uses the browser's HTML parsing, it resolves entities exactly as a page would — including obscure named ones. That's accurate, but means decoding assumes the input is HTML-entity text, not some other escaping scheme.

How it compares

Encoding entities by hand is error-prone — it's easy to escape the angle brackets but forget the ampersands, which then double-encode or break. This does it consistently in both directions, and the browser-based decoder handles every entity a real browser would, not a limited subset.

For output in a live application, your template engine or framework almost always auto-escapes HTML for you (React, Vue, and server templates do this by default), and you should rely on that rather than manually encoding — manual encoding on top of auto-escaping causes double-encoding bugs. Use this tool for one-off jobs: preparing a code sample to display, decoding entity-laden text you received, or checking what a given entity resolves to.

HTML Entity Encoder/Decoder — FAQ

What are HTML entities?

They're codes that represent characters which have special meaning in HTML (like < > &) or that are hard to type. Writing &lt; tells the browser to display a literal < instead of starting a tag. They come in named (&amp;), decimal (&#38;), and hex (&#x26;) forms.

When do I need to encode HTML entities?

When you want to display literal HTML or special characters on a page — a code sample, or user text — without the browser interpreting them as markup. It's also a baseline step for safely putting untrusted text into HTML content.

What's the difference between the two encode modes?

'Special chars only' escapes just the characters that affect HTML (& < > and quotes), keeping the rest readable — this is what you normally want. 'All characters' encodes every character as a numeric entity, which is used for obfuscation or forcing a specific representation.

Does decoding handle all entity types?

Yes. Decoding uses the browser's HTML parser, so it resolves named entities (like &copy;, &mdash;), decimal references (&#169;), and hexadecimal references (&#xA9;) the same way a web page would.

Should I use this instead of my framework's escaping?

For live application output, rely on your framework's automatic escaping (React, Vue, server templates) to avoid double-encoding. Use this tool for one-off tasks like preparing a snippet to display or decoding entity-encoded text you received.

Useful references

Advertisement

Learn more

Explore more tools

200+ free tools that run in your browser.

Browse all tools →