Skip to main content
Tools Star Hub

Developer Tools

How to Escape HTML So It Shows as Text

By Tools Star Hub Editorial Team · Published

HTML encoding replaces characters that would start a tag or an entity, so the browser shows them instead of running them. A less-than sign becomes <, a greater-than sign becomes >, an ampersand becomes &, a double quote becomes ", and an apostrophe becomes '.

Decode turns common named entities and numeric character references back into characters. The text is never inserted as a page, and it is never run.

How to encode or decode HTML

  1. Paste the markup or the entities. Encode starts from characters you want to display. Decode starts from entities.
  2. Press Encode or Decode. Copy the result. Encoded tags can be shown in a tutorial or a comment.
  3. Expect common entities on the way back. An uncommon named entity can stay as typed. The decoder covers common named entities and numeric references.
  4. Use a different tool to convert a document. Markdown to HTML and HTML to Markdown convert between those writings. This page only escapes or unescapes characters.
How to Escape HTML So It Shows as Text — Tools Star Hub

Example

A tag with an ampersand

The markup <div class="x">Hello & welcome</div> encodes to &lt;div class=&quot;x&quot;&gt;Hello &amp; welcome&lt;/div&gt;.

FAQ

Will the HTML run on this page?
No. The input is treated as text. It is not inserted with innerHTML.
Why encode the ampersand?
An unescaped ampersand starts an entity. &amp; shows an ampersand.
What does decode accept?
Common named entities and numeric character references. An uncommon name can remain as you typed it.
Is this a minifier?
No. A minifier removes space from markup. This tool changes special characters into entities, or the reverse.

To show a tag as text, or to turn entities back into characters, use the HTML Encoder.