HTML Entity Encoder & Decoder

Encode special characters as HTML entities or decode them back to text.

Your input is processed on this page and is not stored by us.

Input
Result

About this tool

HTML uses characters such as <, >, & and quotes as part of markup syntax. When those characters are meant to appear as text, they need to be represented safely. The HTML Entity Encoder and Decoder converts special characters to entities and restores entity text to readable characters.

Encoding is especially important when displaying code snippets or user-provided text, but entity conversion alone is not a complete defense against cross-site scripting. Applications should escape output for the exact HTML, attribute, URL or JavaScript context and avoid treating untrusted strings as markup. Use this utility for inspection and preparation; use your framework's context-aware escaping functions in production templates. For percent-encoded URL parameters, the Query String Parser is the more appropriate tool.

How to use it

  1. Select Encode when literal text must be displayed safely inside HTML content.
  2. Select Decode when you need to inspect text containing named or numeric entities.
  3. Enable non-ASCII encoding only when the target system requires an ASCII-only representation.
  4. Convert the text and verify that quotes, ampersands and angle brackets behave as expected.
  5. Use context-aware application escaping when the value will be inserted into a live template.

Useful ways to apply it

  • Displaying HTML tags as code instead of allowing the browser to parse them.
  • Decoding copied content that contains &amp; or numeric entities.
  • Preparing examples for documentation, tutorials and support messages.
  • Checking whether text has been encoded once or accidentally double-encoded.
  • Learning which characters have special meaning in markup.

Frequently asked questions

What is the difference between encoding and sanitizing?
Encoding represents characters safely for a specific output context. Sanitizing attempts to remove or allow selected markup. They are different operations and may both be needed.
Why does an ampersand become &amp;amp;?
The ampersand starts an entity reference, so a literal ampersand is encoded as &amp;amp; in HTML source.
Should all non-ASCII text be converted to entities?
Usually no. Modern UTF-8 pages can display international characters directly. Encode them only for a legacy or constrained system that requires it.
Can I decode repeatedly encoded text?
Run decoding carefully one layer at a time. Repeated decoding of untrusted content can turn harmless text back into active markup if it is later inserted unsafely.

Privacy

Your input is processed on this page and is not stored by us.