Encode and decode HTML entities. Convert special characters like <, >, &, " to their HTML entity equivalents for safe embedding in HTML documents.
HTML entity encoding converts special characters to their HTML entity representations (e.g., < becomes <). This is essential for safely displaying user-generated content in HTML, preventing XSS attacks, and including characters that have special meaning in HTML. Decoding reverses the process, converting entities back to their original characters.
HTML Entity = & + name or # + decimal/hex code + ;HTML entities come in three forms: named entities (< for <), decimal numeric entities (< for <), and hexadecimal numeric entities (< for <). The five mandatory entities in HTML are: & (&), < (<), > (>), " ("), and ' (').
| Input | Output |
|---|---|
| <div class="test">Hello & World</div> | <div class="test">Hello & World</div> |
| <script>alert(1)</script> | <script>alert(1)</script> |
| © 2024 • Registered® | © 2024 • Registered® |