Encoding

HTML Entities Encode/Decode

Encode and decode HTML entities — safely display special characters on a page.

HTML entities are a way to write characters that would otherwise break markup (<, >, &) or have no keyboard key, as safe text sequences like &lt; or &amp;. This tool encodes and decodes such entities right in your browser.

How to use it

Common uses

Things to keep in mind

HTML entity escaping only protects against XSS via a page's text content — it does not protect a JavaScript context (innerHTML, eval) or href/src attributes containing unvalidated URLs.

Encode exactly at the point where text gets inserted into HTML, not ahead of time when saving to a database — otherwise the data gets mangled when reused outside an HTML context.

Article about this tool: HTML Entities: how to safely output special characters on a page

Frequently asked questions

What's the difference between named and numeric HTML entities?

Named entities like &amp; are easier to read, while numeric entities like &#38; or &#x26; (decimal or hex) work for any character, including ones without a named entity. Both render identically in a browser.

When do I actually need to encode HTML entities?

Encode characters like < > & " ' whenever you're inserting user-provided or dynamic text into HTML markup, so the browser treats them as text rather than as part of a tag or attribute.

What's the difference between "Basic" and "All characters" mode?

Basic only escapes the characters that are structurally significant in HTML (like < > & " '), while "All characters" also converts other non-ASCII characters to numeric entities, which can be useful for older or strict parsers.

Do I need to escape text in an attribute differently than in the page body?

The core characters (<, >, &) are escaped the same way, but inside a quoted attribute it's also critical to escape the specific type of quote the attribute is delimited by — otherwise the value will "break" earlier than expected.

Does HTML escaping protect against all kinds of XSS?

No. It closes off the most common vector — inserting text into HTML content — but it doesn't protect against XSS through a JavaScript context (for example, innerHTML followed by code execution) or unvalidated URLs in href/src.

Articles: Encoding

Base64: why encoding is needed and how it works

How Base64 turns binary data into ASCII text and where that is actually needed.

Base32: how it differs from Base64 and when it is more convenient

The case-insensitive Base32 alphabet and scenarios where it beats Base64.

URL Encode/Decode: percent-encoding in links

How special characters in URLs and query parameters turn into %XX sequences.

JWT: token structure and what "decoding" a JWT actually means

The header, payload, and signature of a JWT, and why decoding is not the same as verifying the signature.

Unicode Escape: what \uXXXX sequences mean

Where \u0041-style sequences in JSON and JS strings come from and what they mean.

ROT13 and the Caesar cipher: simple character substitution

Why shifting by 13 letters makes ROT13 self-inverse, and why anyone still uses it today.

Punycode: how internationalized domains work in DNS

How a domain with non-Latin characters gets converted into an ASCII form with the xn-- prefix.

Morse code: how text becomes dots and dashes

The principle behind encoding letters as dots and dashes, and where Morse code is still used today.

Data URI: when to embed images directly in code

How a data: URI embeds a file’s contents directly in HTML or CSS, and when that is worth it.

Gzip + Base64: compressing data for text-based transfer

Why compressed binary data also gets Base64-encoded before going into a text field.

XML Entities: escaping characters in XML documents

The five required XML entities without which a document breaks during parsing.