HTML Entity Encoder
Encode and decode HTML entities online. Convert special characters to HTML-safe strings.
About HTML Entities
HTML entities are special codes used to display reserved characters in HTML. For example, < becomes < and & becomes &. This tool encodes and decodes these entities.
Video Tutorial
2:25Video coming soon — full transcript available below
Chapters
Full transcript searchable
Why HTML entity encoding prevents XSS attacks
Welcome to this HTML Entity Encoder tutorial. When you display user-provided content in an HTML page, special characters can break your HTML structure or allow malicious script injection — this is called Cross-Site Scripting or XSS. The characters that must be encoded are: angle brackets less-than and greater-than (used for HTML tags), the ampersand (used for entities), double quotes and single quotes (used in HTML attributes). Converting these to HTML entities makes them display as text instead of being interpreted as HTML markup.
Encode text with special characters
Open the HTML Entity Encoder on ToolPilot.dev. Paste text containing special characters — for example: a script tag with an alert, or a string with ampersands and quotes. Click Encode. The output shows the entity-encoded equivalent: less-than becomes <, greater-than becomes >, ampersand becomes &. When this encoded string is rendered in a browser, it displays the literal characters rather than executing as HTML or JavaScript.
Decode HTML entities back to text
To decode entities back to readable text, paste HTML-encoded content and click Decode. This converts < back to the less-than sign, & back to ampersand, " back to double quotes, and so on. This is useful when working with HTML stored in databases, reading API responses that return escaped HTML, or analyzing HTML source code where entities are used for special characters.
Named vs numeric entities
HTML entities come in two forms: named entities like & < > " and numeric entities using decimal or hexadecimal notation. Named entities are human-readable. Numeric entities work for any Unicode character — the copyright symbol can be written as © in decimal or © in hexadecimal. The encoder outputs both forms so you can choose which format to use in your templates.
Use case: safe HTML templates and CMS content
Server-side templating frameworks handle HTML encoding automatically when you use their escape functions. But there are cases where manual encoding is needed: generating HTML in shell scripts, inserting content into legacy systems without automatic escaping, creating email HTML templates, or writing CMS content that includes code examples with angle brackets. This tool encodes the content so it displays correctly.
Wrap-up
HTML entity encoding is a fundamental web security concept. The HTML Entity Encoder on ToolPilot.dev encodes and decodes entities instantly in your browser. For production applications, always use your framework's built-in escaping functions rather than manual encoding — Jinja2 auto-escapes by default, React's JSX escapes by default, and PHP's htmlspecialchars() handles the common cases. Visit ToolPilot.dev for this and 19 other free developer tools.
Transcript covers all 6 chapters (2:25 total).