HTML encode
Convert special characters to their HTML entity equivalents. Paste any text and get an HTML-encoded version where characters like <, >, &, and " are replaced with <, >, &, and ".
How it works
Encoding runs five replace calls in a fixed order, & first so the entities it inserts are not escaped a second time, turning &, <, >, " and ' into &, <, >, " and '. Decoding lets the browser's own HTML parser reverse the process: the text, with every < escaped first, is parsed inside a detached <textarea>, which never creates elements. Both run entirely in your browser.
Processing runs in your browser
All encoding and decoding happens locally in your browser tab. Our servers are not involved at any point.
Related operations
For percent-encoding URL components, try URL encode. To encode binary blobs or images as text, use Base64. For previewing escaped markup, see the Markdown preview.
Frequently asked questions
- What is HTML encoding?
- HTML encoding replaces characters that have special meaning in HTML, such as < (less-than) and & (ampersand), with entities (< and &), so the browser shows them as text instead of reading them as markup.
- Why is HTML encoding important?
- When displaying user-supplied text in HTML, failing to encode it can allow HTML injection or cross-site scripting (XSS) attacks. Encoding ensures the text is displayed literally rather than interpreted as markup.
- What characters get encoded?
- At minimum: & becomes &, < becomes <, > becomes >, " becomes ", and ' becomes '. This tool encodes all five.
- Does this tool send my data anywhere?
- All processing runs in your browser with JavaScript. Our servers are not involved at any point.
Last reviewed September 30, 2026
Other pages for this tool
Related tools
- Background reading: Complete guide to developer tools