Skip to content

HTML Encoder/Decoder

Encode and decode HTML entities for safe display

Input

Output

Common HTML Entities

&

&

Ampersand

<

&lt;

Less than

>

&gt;

Greater than

"

&quot;

Double quote

'

&#39;

Single quote

␣

&nbsp;

Non-breaking space

©

&copy;

Copyright

®

&reg;

Registered

™

&trade;

Trademark

€

&euro;

Euro

£

&pound;

Pound

¥

&yen;

Yen

—

&mdash;

Em dash

…

&hellip;

Ellipsis

←

&larr;

Left arrow

→

&rarr;

Right arrow

•

&bull;

Bullet

°

&deg;

Degree

Examples

Before Encoding:

<script>alert("Hello & World")</script>

After Encoding:

&lt;script&gt;alert(&quot;Hello &amp; World&quot;)&lt;/script&gt;

Frequently asked questions

Why do I need to encode HTML?

HTML encoding prevents browsers from interpreting characters as code. Essential for security (prevents XSS attacks), displaying code examples, and showing characters like <, >, &, and quotes literally.

What characters must be HTML encoded?

At minimum: < (&#60; or &lt;), > (&#62; or &gt;), & (&#38; or &amp;), " (&#34; or &quot;), and ' (&#39; or &apos;). Encode anything that could be interpreted as HTML.

Should I encode all user input?

Yes, always encode user-provided content before displaying in HTML. This is your primary defense against XSS attacks. Modern frameworks often handle this automatically.