HTML Encode
Encode special characters to HTML entities — paste, encode, and copy instantly.
Encoded HTML will appear here...About HTML Encode
HTML Encode is a free online tool that converts the five characters with reserved meaning in HTML — ampersand (&), less-than (<), greater-than (>), double quote ("), and single quote (') — into their safe entity equivalents: &, <, >, ", and '. Pasting the encoded result into an HTML document guarantees the browser renders those characters as visible text rather than interpreting them as markup.
The need comes up constantly in web development: embedding a code snippet inside a blog post without breaking the page, rendering user-submitted comments without opening an XSS vector, writing a data attribute that contains quotes, or generating static HTML from a template where the data may contain arbitrary text. Rather than memorising entity names or hand-editing each character, you paste the raw text, click Encode, and copy the safe output in one step.
Every conversion runs entirely in your browser. No text is uploaded, logged, or passed through any server — so even internal code samples, API keys shown in documentation drafts, or confidential error messages can be encoded without leaving your machine. The tool is free, requires no account, and has no rate limits.
Key Features
Encodes all five reserved HTML characters
Converts &, <, >, ", and ' to &, <, >, ", and ' — the complete set needed to safely embed arbitrary text inside HTML documents and attributes.
100% client-side processing
Encoding runs in your browser using plain JavaScript string replacement. Nothing is sent to a server, making it safe for proprietary code, internal docs, and anything else you would not want logged.
Correct attribute and content encoding
The output is safe both inside HTML element content and inside quoted attribute values, covering the two most common embedding contexts at once.
Instant one-click copy
A copy button lets you grab the encoded result immediately and paste it straight into your template, CMS, or code editor without selecting text manually.
Handles mixed content cleanly
Text that already contains plain words alongside reserved characters is encoded accurately — only the five special characters are replaced; all other characters are left untouched.
No limits, no sign-up
Encode documents of any length as often as you need. There are no file-size caps, no daily quotas, and no account required.
How to Use
Enter HTML
Type or paste the text containing special characters into the input pane.
Encode
Click "Encode" to convert special characters to HTML entities.
Copy Result
Use the copy button to grab your encoded HTML for safe display.
Example
A raw code snippet containing angle brackets, an ampersand, and quotes is encoded so every reserved character becomes its safe HTML entity.
<script>alert("Hello & 'World'")</script> <script>alert("Hello & 'World'")</script> Common Use Cases
- arrow_circle_right
Displaying code snippets in blog posts
When embedding a code sample inside an HTML page, angle brackets in the snippet would be treated as tags. Encoding the snippet first ensures every < and > renders as a visible character instead of breaking the markup.
- arrow_circle_right
Sanitising user-generated content before rendering
Encoding user input before inserting it into an HTML template is a foundational defence against reflected XSS. The encoded text cannot be parsed as executable markup by the browser.
- arrow_circle_right
Writing values into HTML attributes
Data attributes, title strings, and alt text that contain quotes or ampersands must be encoded before being placed inside quoted attribute values, otherwise the attribute terminates early and the HTML is malformed.
- arrow_circle_right
Generating static HTML from templates or CMS exports
Template engines and CMS data exports often produce plain-text field values. Running those values through HTML Encode before inserting them into a static page prevents accidental markup injection.
- arrow_circle_right
Creating documentation that shows HTML as text
Technical writers and help-desk teams who need to display raw HTML examples in web-based documentation encode the samples so readers see the literal tag syntax rather than rendered elements.