How the browser parses
The moment a browser sees < it starts treating the text as markup. If you want the four characters
Steps
- Paste the content; the sample is a paragraph tag with a class attribute.
- Click Convert, and ⇅ flips between encoding and decoding.
- Enable non-ASCII to numeric entities to turn Chinese into forms like 中, useful for legacy systems and mail clients with mismatched charsets.
- Load example shows a standard case; copy the output when done.
What the non-ASCII option changes
By default only the five named entities are escaped and Chinese stays readable — the shortest, most legible output for a UTF-8 page. With the option on, Chinese becomes decimal entities that render anywhere, at the cost of roughly eight characters per glyph and much harder reading. The right choice depends on the downstream system, not on maximal caution.
Three common misuses
Double encoding is the first: escaping content that already contains & produces < on screen, so users see source code. Decoding into the DOM is the second: turning <script> back into tags and injecting it is self-inflicted cross-site scripting; show code inside textarea or pre instead. Missing escapes are the third: pasting a nickname straight into an attribute lets a quote break out of it, a classic XSS entry. The rule of thumb is escape five characters for text nodes, escape quotes for attributes, and use JSON or CSS escaping inside script and style blocks rather than HTML entities.