TASK
Encode special characters for safe insertion into HTML
Escape <, >, &, ", and ' in user-supplied text so it can be placed inside HTML without triggering XSS or breaking markup.
- 1
Five characters have special meaning in HTML: < and > delimit tags, & starts entities, " and ' delimit attribute values. Leaving them unescaped in user content allows XSS attacks and breaks markup.
- 2 HTML Escape →
Paste text containing <, >, &, quotes. The tool replaces them with < > & " ' — safe for both element content and attribute values.
- 3 HTML Entity Encoder →
For full Unicode entity encoding (not just the five specials), use this tool to convert all non-ASCII characters to numeric entities as well.
- 4 HTML Entity Decoder →
Reverse the process: paste entity-encoded text to recover the original characters for display or editing.
Frequently asked questions
- What is the difference between html-escape and html-entity-encode?
- html-escape only converts the five HTML-special characters (< > & " '). html-entity-encode converts all non-ASCII characters to numeric entities too, producing fully ASCII-safe output.
- Is escaping enough to prevent XSS?
- Escaping prevents XSS when inserting text into element content or quoted attributes. It is NOT sufficient for unquoted attributes, URL attributes (use url-encode), or script/style contexts — those need context-specific handling.
Workflows that solve this
Learn more
Want to understand why?
How to Implement Content Security Policy
An intermediate-level guide covering csp, security, xss. Includes step-by-step instructions, common errors, troubleshooting tips, and security considerations for csp. TUTORIAL
How to Minify HTML
Reduce HTML file size by removing whitespace, comments, and redundant attributes. TUTORIAL
HTML CDATA
HTML CDATA wraps content containing < and & inside <script>/<style> with <![CDATA[...]]> in XHTML to avoid parsing errors. GLOSSARY
HTML Comment
An HTML comment uses <!-- ... --> to wrap explanatory text that is not rendered, used for documentation notes and conditional comments. GLOSSARY
Related tools
HTML Escape
Escape or unescape HTML special characters online. Free, private, and 100% client-side. TOOL
HTML Entity Encoder
Encode text to HTML entities online. Free, private, and 100% client-side. TOOL
HTML Entity Decoder
Decode HTML entities back to readable text online. Free, private, and 100% client-side. TOOL