Home › Blog › How to escape HTML characters
Developer Tools guide

How to escape HTML characters

To show code or user text on a page, special characters must be escaped. The encoder does it for you.

Open the HTML Encoder tool

Step by step

  1. Paste your text. Paste the text or code.
  2. Choose options. Optionally encode non-ASCII characters.
  3. Copy the result. Use the Copy button.

Tips for better results

  • Always escape user-provided text before inserting it into HTML.
  • Turn on Encode all non-ASCII characters to get numeric entities for letters like é.
  • Quotes are encoded so the result is also safe inside attributes.

Limits to know

  • Formats: Plain text
  • Size: Limited by browser memory
  • Notes: Runs fully in your browser. Very large inputs (several MB) can slow the page.

At a glance

ToolHTML Encoder
CategoryDeveloper Tools
Works withPlain text
Size limitLimited by browser memory
Where it runsIn your browser tab; your input is not uploaded
CostFree, no sign-up

Frequently asked questions

Which characters are encoded?

The five that matter in HTML: & < > " and the apostrophe, plus every non-ASCII character if you choose.

Is this enough to prevent XSS?

It is the basic step for text content. Context matters, so follow your framework’s security guidance.

If something does not work

  • The result is empty. Check that you typed or pasted text into the input box and that the options are not hiding everything.
  • The page feels slow. Very large text slows any browser tool. Work on smaller parts.
  • Characters look wrong. Make sure the text is saved as UTF-8 in the program you copied it from.
  • Copy does not work. Some browsers block automatic copying; select the result and copy it yourself.

Still stuck? Use Report a Problem and tell us the tool, your browser and what happened, or read the Help Center.

Related tools and guides

More tools like this are in Developer Tools, or browse all tools.