OnlineNotes Logo

HTML Escape/Unescape

Convert between raw text and HTML entities for safe markup rendering and content workflows.

Input

Output

Ready

Mode

Escape

Input chars

0

Output chars

0

When to use this tool

Use HTML escaping when showing literal markup in templates, docs, or logs.

Unescape mode is useful when cleaning encoded snippets from exports and APIs.

Frequently asked questions

When should I escape HTML?

Escape HTML when rendering user-provided text in markup contexts to avoid accidental tag interpretation.

Can I unescape encoded HTML entities?

Yes. Switch to unescape mode to convert entities like ampersand, less-than, and quote codes into text.

Does this tool work with multiline input?

Yes. It supports multiline text and preserves line breaks in output.

Related tools

HTML escape and unescape tool for safe template rendering

Use this HTML escape tool when text has to appear literally on a page, such as a code example in a doc or user-provided text in a template.

Unescape mode reverses entity-encoded strings from exports, API responses, or old databases, and it knows the full set of HTML named entities because the browser decodes them.

How it works

  1. Choose Escape or Unescape. Switching mode converts the current input at once. After editing text, press Run conversion.
  2. Escape replaces exactly five characters: & with &amp;, < with &lt;, > with &gt;, " with &quot;, and ' with &#39;. The & goes first, so the new entities are not escaped again.
  3. Unescape asks the browser to decode the text inside a textarea element. It handles named entities (&eacute;), decimal (&#233;), and hex (&#xE9;). Tags are only treated as text, so no script runs.
  4. The counters show the mode and the input and output length, so you can see how much escaping added.

Worked example

Input

<a href="/x?a=1&b=2">Tom's café</a>

Output

&lt;a href=&quot;/x?a=1&amp;b=2&quot;&gt;Tom&#39;s café&lt;/a&gt;

Escape mode. The é is left as it is, since it is not one of the five characters. Pasted into an HTML page, this displays as the original text instead of creating a link. Run Unescape on the output to get the input back.

Edge cases and limits

  • Escaping is not idempotent. Running it twice gives double-escaped text: &lt; becomes &amp;lt;. This is correct when you want to show an entity literally, and a bug when you do not.
  • This escaping fits HTML text and quoted attributes. It does not make a value safe inside a script block, a CSS rule, or a javascript: URL. Those need their own escaping, so use your template engine's escaping in production.
  • Unescape follows browser rules. "&amp" with no semicolon still decodes to &, while an unknown entity such as &foo; stays as typed. Unescape runs once, so &amp;lt; becomes &lt;, not <.
  • Non-ASCII text is not converted to entities, so é stays é and does not become &eacute;. Your page must be served as UTF-8 for it to display correctly.

When to use it

  • Escape text before you put it in a template by hand.
  • Decode HTML entities from imported CSV or JSON data.
  • Prepare code snippets for a help center article.
  • Check how quotes and angle brackets come out when escaped.