Skip to content

HTML Encoder & Decoder

Convert special characters to HTML entities or decode HTML entities back to their original characters for safe web display.

0 characters 0 words

Related Tools

Case Converter Base64 Encoder & Decoder URL Encoder & Decoder Strip HTML Tags Invisible Character Detector

How to Use

  1. Enter Text or HTML Entities — Paste text containing special characters to encode, or paste a string with HTML entities to decode.
  2. Select Encode or Decode — Choose Encode to convert special characters into HTML entities (optionally including accented letters and emoji as numeric entities), or Decode to restore entities back to their original characters.
  3. Use the Output — Click Encode / Decode, then copy or download the result for safe insertion into HTML source code or documents.

About the HTML Encoder & Decoder

The HTML Encoder & Decoder converts characters that have a special meaning in HTML into entities, and turns entities back into ordinary characters. Developers use it to show code samples on a web page and to escape user-supplied text before it goes into a template or attribute. Writers and editors use the decoder when a CMS field, feed or export shows &, ' or — instead of the characters themselves.

How it works

Worked examples

InputModeOutput
<p class="note">Tom & Jerry's</p>Encode&lt;p class=&quot;note&quot;&gt;Tom &amp; Jerry&#39;s&lt;/p&gt;
if (a < b && c > d)Encodeif (a &lt; b &amp;&amp; c &gt; d)
Café — 5 °CEncode, non-ASCII as hexCaf&#xE9; &#x2014; 5 &#xB0;C
🚀Encode, non-ASCII as decimal&#128640;
Caf&eacute; &mdash; 5&nbsp;&deg;CDecodeCafé — 5 °C (with a non-breaking space before °C)
&amp;lt;Decode&lt; (one layer removed)

Edge cases

When to use it

Escaping is the standard defense against cross-site scripting when untrusted text goes into HTML: encoded, <script> is displayed instead of run. HTML escaping is only right for HTML text and attributes, though. Inside a URL, a script block or CSS, use the escaping that context needs; for URLs that is the URL Encoder & Decoder. Numeric entities also help when an email template or older system mishandles UTF-8. To remove markup instead of displaying it, use Strip HTML Tags, and see the HTML Entities reference guide for the common named entities.

Encoding and decoding happen in your browser; the code or content you paste is never uploaded.

Frequently Asked Questions

What are HTML entities?

HTML entities are special codes that represent characters which have reserved meaning in HTML or cannot be typed easily. They begin with an ampersand (&) and end with a semicolon (;). For example, < represents the less-than sign (<), & represents the ampersand (&), and © represents the copyright symbol.

Why do I need to encode characters for HTML?

Characters like <, >, &, and " have special roles in HTML syntax. If you include a raw < in your content, the browser interprets it as the start of an HTML tag. Encoding it as < tells the browser to display the literal character instead of parsing it as markup. This prevents rendering errors and helps prevent cross-site scripting (XSS) vulnerabilities. The encoder converts &, <, >, double quotes, and single quotes (as '), so the output is also safe inside quoted attribute values.

What is the difference between named and numeric HTML entities?

Named entities use descriptive labels (e.g., ♥ for a heart symbol). Numeric entities use the character's Unicode code point in decimal (♥) or hexadecimal (♥) form. Named entities are more readable, but numeric entities cover every Unicode character regardless of whether a name exists.

How does HTML encoding prevent XSS attacks?

Cross-site scripting (XSS) occurs when an attacker injects malicious HTML or JavaScript into a web page. By encoding user-supplied input — converting < to < and > to > — the browser treats the content as display text rather than executable code, neutralizing the attack vector.

Does the tool handle emojis and special symbols?

Yes. Tick "Encode non-ASCII characters and emoji as numeric entities" and every character outside the basic ASCII range, including accented letters, symbols, and emoji, is converted to a numeric HTML entity. Hexadecimal is the default (the rocket emoji becomes 🚀), and decimal is available (🚀). This keeps the markup pure ASCII for systems that mishandle UTF-8. Leave the option off to keep those characters as they are, which is fine for any page served as UTF-8.

Can I decode HTML entities found in web scraping output?

Absolutely. When you scrape web content, text often contains encoded entities like &, ", and numeric codes. Switch to Decode and paste the scraped text to restore named, decimal, and hexadecimal entities to their original characters. Decoding only converts entities: any tags in the text are left as plain text and are never run.