HTML Encode
Escape characters that have a special meaning in HTML so your markup examples render as text instead of being interpreted.
- Runs in your browser
- Free, no sign-up
What this tool gives you
Same as htmlspecialchars
Encodes & < > " and the apostrophe exactly like PHP with ENT_QUOTES.
Optional numeric entities
Turn accents, symbols and emoji into &#NNNN; references for ASCII-only files.
Live preview
The encoded output appears while you type.
Frequently asked questions
When should I HTML-encode?
Whenever untrusted or literal text is placed inside HTML: user comments, code samples, attribute values. It is the primary defence against cross-site scripting.
Why encode the apostrophe?
Attribute values wrapped in single quotes would break otherwise. ' is safe in every context and is what PHP htmlspecialchars emits with ENT_QUOTES.
Do I need to encode non-ASCII text?
Not when the page declares UTF-8, which almost every page does today. The option exists for legacy systems, email templates and ASCII-only files.
Is this the same as URL encoding?
No. HTML entities protect text inside markup; percent-encoding protects text inside URLs. Use the URL Encode tool for query strings.