HTML Escape

Escape special characters in HTML strings.

Local Your input is processed locally in your browser. Found a problem? Report an issue

What HTML Escape does

HTML Escape replaces the five characters that can end text or an attribute value in HTML with character references, so the text is shown as written instead of being read as markup.

The apostrophe becomes ' rather than ', because ' was not part of HTML before HTML5 and older parsers do not know it. Everything else, including accented letters and emoji, is kept.

HTML Escape examples

The built-in sample

Input

say "hello" & <b>bye</b>

Output

say &quot;hello&quot; &amp; &lt;b&gt;bye&lt;/b&gt;

This is the input that the Load sample button fills in.

Markup shown as text

Input

<a href="/x">Tom & Jerry's</a>

Output

&lt;a href=&quot;/x&quot;&gt;Tom &amp; Jerry&#39;s&lt;/a&gt;

The result displays the tag instead of creating a link.

Each output was produced by running this tool on the input above it.

How it works

Each of these characters is replaced; all other characters are copied unchanged.

CharacterWritten as
&&amp;
<&lt;
>&gt;
"&quot;
'&#39;

Details and limits

  • Safe for element content and for attribute values in quotes. It is not enough inside <script> or <style>, in an unquoted attribute, or in a URL; use URL Encode for URLs.
  • For XML, use XML Escape, which writes &apos; and checks for characters XML forbids.

Questions

Do I need to escape accented letters?

No. In a page served as UTF-8, letters such as é can be written directly. Only the characters that have a meaning in markup need escaping.