Skip to tools

Encoders / Decoders

HTML Entity Encode

Showing code on a web page or inserting user text into HTML requires escaping characters like <, >, & and quotes. The HTML Entity Encoder converts them into entities such as &lt; and &amp; so browsers display them as text instead of interpreting them as markup.

Escaping is a key part of preventing broken layouts and cross-site scripting in templates.

How to use the HTML Entity Encode

  1. 1Use the HTML Entity Encode right on this page, or open the full workspace for history, sharing and every other tool.
  2. 2Paste your input, upload a file, or drag and drop a file onto the input box (up to 25 MB).
  3. 3The result appears in the output panel automatically and updates when you change the input or an option.
  4. 4Use Copy Output or Download to save the result. Nothing is uploaded to a server.

Example

A small HTML snippet is escaped so it can be shown as text on a page.

Input
<div class="hi">Hello & welcome</div>
Output
&lt;div class=&quot;hi&quot;&gt;Hello &amp; welcome&lt;/div&gt;

When to use it

  • Displaying HTML or XML snippets inside a blog post or documentation page
  • Escaping text before inserting it into an HTML attribute
  • Preparing content for systems that do not escape automatically

Tips and common mistakes

  • Most templating engines escape automatically — avoid double escaping.
  • Encode quotes when the text goes inside an attribute value.
  • Use HTML Entity Decode to reverse the process.

Frequently asked questions

Which characters are encoded?

The characters with special meaning in HTML: <, >, &, double quotes and single quotes.

Is this enough to prevent XSS?

It is an important layer, but context matters — scripts and URLs need their own escaping rules.

TutorialHTML, CSS and JavaScript beautification: a quick tour

Related tools

Ready to try it?

Free, no sign-up, and your data never leaves your browser.