HTML Encoder & Decoder Online

Encode HTML characters to entities or decode HTML entities back to text. Essential for preventing XSS attacks and displaying code safely.

Runs entirely in your browser - no data is sent to any server.

Common HTML Entities

&&
<&lt;
>&gt;
"&quot;
'&#39;
space&nbsp;
©&copy;
®&reg;
&trade;
&euro;
£&pound;
&bull;
&mdash;
&ndash;
&rarr;
&larr;
&ne;
&le;

HTML Encoding Example (XSS Prevention)

Before (dangerous):
<script>alert(1)</script>
After encoding (safe):
&lt;script&gt;alert(1)&lt;/script&gt;

Encoded scripts display as text instead of executing.

HTML Encode vs Escape vs Sanitize

Encode

Convert characters to HTML entities. Preserves all content as displayable text.

Escape

Same as encoding. Terms are often used interchangeably for HTML.

Sanitize

Remove or strip dangerous tags entirely. More aggressive than encoding.

Essential HTML Entities

&->&amp;
<->&lt;
>->&gt;
"->&quot;
'->&#39;
(space)->&nbsp;

Common Symbol Entities

©&copy;
®&reg;
&trade;
&euro;
£&pound;
¥&yen;

Frequently Asked Questions

What is HTML encoding?

HTML encoding converts special characters like <, >, & into HTML entities so they display as text instead of being interpreted as markup.

When should I encode HTML?

Encode HTML when displaying user input, showing code snippets, or whenever special characters need to appear as text rather than HTML.

Does HTML encoding prevent XSS?

Yes. By converting < and > to entities, injected scripts become harmless text instead of executable code.

HTML encoding vs URL encoding?

HTML encoding is for displaying text in web pages. URL encoding is for safe transmission in URLs. Different purposes, different formats.

Working with web data? Check out our URL Encoder, Base64 Encoder, or JSON Formatter.