Encode HTML entity

Encode HTML-sensitive characters as safe named or numeric references.

freeworks offlinenothing uploaded
ToolHTML Entity Encoder
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Characters that could become markup are replaced with references according to text or attribute context; existing entities can be preserved or encoded again by mode. Numeric references retain the same Unicode code point.

  • Common named references cover markup delimiters.
  • Numeric references handle characters without short names.

Worked example

Escape HTML for safe display
Encode angle brackets, ampersands, and quotes to prevent XSS and render code snippets safely
Input
											<script>alert("XSS & injection")</script>
										
Output
												&lt;script&gt;alert(&quot;XSS &amp; injection&quot;)&lt;/script&gt;
											

When to use this

Templates, code samples, and safe scraper storage encode HTML text.

Edge cases

  • Quotes need attribute-context escaping.
  • Encoding an existing &amp; twice creates visible entity text.
  • Emoji can remain UTF-8 or become numeric references.

References