Skip to main content
ToolsHub

HTML Encoder / Decoder

Encode HTML special characters to entities or decode entities back to HTML. Essential for web developers.

Files never leave your browser
Common HTML entities reference
CharacterEntity
&&
<&lt;
>&gt;
"&quot;
'&apos;
©&copy;
®&reg;
&trade;
(non-breaking space)&nbsp;
&mdash;

How to use HTML Encoder / Decoder

The HTML Encoder / Decoder converts special characters to HTML entities and back again. Characters such as <, >, &, " and ' have reserved meaning in HTML markup and must be replaced with their entity equivalents (&lt;, &gt;, &amp;, &quot;, &#39;) before being inserted into HTML documents. This prevents cross-site scripting (XSS) vulnerabilities and ensures that user-generated content displays correctly in browsers.

  1. Paste the text you want to encode or decode into the input field.
  2. Click Encode to replace HTML special characters with safe entity references.
  3. Click Decode to convert HTML entities back to their original characters.
  4. Optionally enable "Encode all non-ASCII" to also convert accented and Unicode characters to numeric entities (&#NNNN;).
  5. Copy the safe output ready for insertion into your HTML template or source code.

Your data never leaves your device — 100% private processing.

Named vs numeric HTML entities

HTML entities come in two forms: named entities such as &amp; and &copy;, and numeric entities in decimal (&#169;) or hexadecimal (&#xA9;) form. Named entities are defined by the HTML specification and cover common typographic and international characters. Numeric entities can represent any Unicode code point, making them universally applicable even when no named entity exists. All modern browsers support both forms.

Essential HTML entities
CharacterNamed entityDecimal entityUse case
<&lt;&#60;Tag-like text in content
>&gt;&#62;Closing angle brackets
&&amp;&#38;Literal ampersand
"&quot;&#34;Quotes inside attribute values
'&apos;&#39;Single quotes in attributes
©&copy;&#169;Copyright symbol
&mdash;&#8212;Em dash in typography

HTML encoding and XSS prevention

Cross-site scripting (XSS) occurs when an attacker injects script tags or event handlers into a page by supplying input that contains HTML syntax. If user-supplied text is rendered into a page without encoding, a string like <script>alert(1)</script> executes as JavaScript. Encoding transforms < to &lt; and > to &gt;, making the injected markup display as inert text. Server-side templating engines (Jinja2, Blade, Thymeleaf) HTML-encode by default; raw output functions such as {{ raw }} bypass this protection and should be used with great caution.

Glossary

HTML entity
A text sequence starting with & and ending with ; that represents a special character in HTML.
XSS
Cross-Site Scripting — an attack that injects malicious scripts into web pages by exploiting unencoded output.
Named entity
An HTML entity identified by a human-readable name, such as &amp; for the ampersand character.
Numeric entity
An HTML entity identified by its Unicode code point in decimal (&#N;) or hex (&#xN;) form.
Sanitization
Removing or neutralising dangerous HTML constructs (scripts, event handlers) from untrusted input.

Related reading

Frequently Asked Questions

Free · No spam

Get weekly tool tips & updates

New tools, power-user tips, and productivity hacks — delivered free every Friday.

No spam, ever. Unsubscribe with one click.

Why use HTML Encoder / Decoder?

  • No installation — use directly from any browser
  • Handles large inputs without crashing or timeouts
  • Syntax highlighting and formatted output for readability
  • Copy to clipboard shortcut for fast workflow integration

Common use cases

  • Validate and format JSON responses from APIs
  • Encode/decode Base64 strings during debugging
  • Generate UUIDs for database seeds or test data
  • Minify CSS or JavaScript before deployment
  • Diff two code snippets to spot regressions

Related Developer Tools

Explore all Developer Tools.