HTML Encoder

Escape HTML special characters to prevent broken or unsafe markup.

Encoding Runs in your browser Shareable link
Text or markup
Escaped HTML

Nothing encoded yet

Paste text or markup to escape the characters an HTML parser would otherwise treat as structure.

Runs entirely in your browser. Your data isn't uploaded — this page makes no network request with anything you type, which you can verify in your browser's network tab. How this works.

What is the HTML Encoder?

HTML encoding replaces characters that the parser treats as markup with named or numeric entities, so text renders as text. It is the mechanical part of preventing cross-site scripting when interpolating untrusted values into a page, and it is also how you show a code sample without the browser executing it.

This tool escapes the five characters that matter — & < > " ' — and can optionally encode every non-ASCII character for systems that cannot carry UTF-8.

How to use it

  1. Paste the text or markup you want to escape.
  2. Pick basic escaping or full non-ASCII encoding.
  3. Press Encode (or Ctrl/Cmd + Enter), then copy the result.

Example

Markup escaped so it renders as text.

Input
<a href="/x">Tom & Jerry</a>
Result
&lt;a href=&quot;/x&quot;&gt;Tom &amp; Jerry&lt;/a&gt;

Features

  • Escapes &, <, >, " and ' — the set needed for both text and attribute contexts
  • Optional numeric encoding of all non-ASCII characters
  • Named or numeric entity output
  • Round-trip check against the decoder so you can verify nothing was lost

Frequently asked questions

Is HTML encoding enough to prevent XSS?
Only in a plain text context, and only if it is applied at the right point. Values placed in a URL attribute, an inline event handler, a style block or a script block need context-specific escaping. Use your template engine's auto-escaping rather than escaping by hand.
Why encode apostrophes?
Because attributes are sometimes delimited with single quotes. Escaping both quote characters means the same escaped value is safe in either.
Esc

Loading the catalog…