Skip to content
yutils
Example

Input (encode mode)

<script>alert("yutils")</script>

Output

&lt;script&gt;alert(&quot;yutils&quot;)&lt;/script&gt;

Note

The five dangerous characters `<`, `>`, `"`, `'`, `&` become entities — required when injecting user input into HTML.

Usage / FAQ

When to use

  • Safely embed user input into HTML to prevent XSS (prefer framework escapes when available)
  • Decode named entities like `&amp;` or `&lt;` back to characters
  • Interpret entities in email or CMS-exported HTML
  • Flatten external RSS / Atom feed content to plain text
  • Look up entity codes for special characters (©, ∞, …)

FAQ

Q.Does it support every entity?
A.Yes — 1000+ HTML5 named entities and numeric forms (`&#65;`, `&#x41;`). Legacy variants like Microsoft's `&apos;` are handled for compatibility.
Q.Does this fully prevent XSS?
A.It escapes the five risky characters. That covers many cases, but attribute / URL / script contexts need their own rules. For production code, prefer DOMPurify or framework-provided escapes.
Q.Are Korean characters left alone?
A.Yes — Korean text and emoji are not entity-escaped. In HTML5 + UTF-8 that's standard.
Fun facts
  • There are 5 predefined entities you must escape inside HTML — `&amp;`, `&lt;`, `&gt;`, `&quot;`, `&apos;`. Among these, `&apos;` was officially defined starting with XHTML — it didn't exist in plain HTML 4, and only entered the standard with HTML5.

    WHATWG — Named characters
  • The number of named HTML entities exploded over time — 33 in HTML 2.0 (1995) → 252 in HTML 4.01 → 2,231 in HTML5 (including emoji and math symbols). HTML5's entity table is effectively un-deprecatable: removing entries would break legacy pages.

    Wikipedia — HTML entities
  • Numeric character references come in two forms — `&#169;` (decimal = ©) and `&#xA9;` (hex). They embed any Unicode code point directly, so every Unicode character is reachable even without a named entity — including emoji via `&#x1F600;`.

    MDN — Character reference