About the Text to HTML
Escape HTML special characters so text shows up on a web page exactly as typed. Paste a code sample, a maths expression or a comment that contains &, <, >, or quotation marks, and this text to HTML entities converter replaces them with &, <, >, " and ', so a browser displays them instead of reading them as markup.
You need this before a code sample goes into a blog post or a documentation page, or when a raw error message has to sit inside an HTML email. Escaping happens as you type, in your browser.
How HTML escaping works here
In HTML, < starts a tag and & starts a character reference. If you put the text <b>Note</b> straight into a page, the browser makes 'Note' bold and the tags vanish. Escaping swaps those characters for named entities that the browser draws as the symbols themselves.
The converter makes five replacements. The ampersand goes first, so the & inside each new entity isn't escaped a second time. Then every < becomes <, every > becomes >, every double quote becomes " and every single quote becomes '. Nothing else is touched: letters, digits, emoji, spaces and line breaks pass through unchanged.
& → & (done first) < → < > → > " → " ' → '
Because quotes are escaped too, the result is safe both between tags, such as inside a p, td or pre element, and inside a quoted attribute value such as title="..." or alt='...'. It doesn't wrap your text in paragraphs, though: the output contains no <p> or <br> tags.
Assumptions and limits
- Apostrophes are escaped as well, so it's becomes it's. Browsers show it as a normal apostrophe; the entity only looks odd if you read the HTML source.
- Line breaks are not turned into <br> tags and blank lines are not turned into paragraphs. Wrap the result in <pre> to keep its line breaks, or add the tags yourself.
- Text that is already escaped gets escaped again: © becomes &copy; and will display literally as ©. Paste the original, unescaped text.
- Non-ASCII characters such as é, ü, ₹ or 😀 stay as they are, which displays correctly on any page saved as UTF-8.
- Escaping protects the display of text, but it is not a complete defence for user input in your own app; let your template engine handle escaping in every context.
Worked examples
Escape HTML tags to show them as code
You want readers to see the markup itself in a tutorial. After escaping, both tags, the ampersand and the quotation marks display as typed.
Input: <b>Bold</b> & "quotes" Output: <b>Bold</b> & "quotes"
A JavaScript comparison in a blog post
Code with less-than, greater-than and logical-and operators. Put the output inside <pre><code> and the line renders exactly as written, instead of the browser treating '< b && b >' as the start of a tag.
Input: if (a < b && b > c) return; Output: if (a < b && b > c) return;
Text that was already encoded
A string copied from another page's source still contains an entity. Escaping it again produces &copy;, which shows the six characters © rather than the © sign. You rarely want that, so start from the plain text.
Input: © already escaped Output: &copy; already escaped
Characters and their HTML entities
The first five are escaped by this tool. The rest are shown for reference, with what the tool does to them.
| Character | HTML entity | What this tool does |
|---|---|---|
| & | & | Escaped |
| < | < | Escaped |
| > | > | Escaped |
| " (double quote) | " | Escaped |
| ' (single quote) | ' | Escaped |
| Non-breaking space | | Left as the same character |
| © | © | Left as © |
| Line break | <br> | Left as a line break |
How to use the Text to HTML
- Paste your text. Type or paste plain text or code into the Input Text box, replacing the sample sentence.
- Check the escaped result. The Result box shows &, <, >, " and ' in place of the special characters as soon as you type.
- Copy into your HTML. Press Copy and paste the result between tags in your page, or inside <pre><code> for code samples.
Frequently asked questions
How do I escape HTML characters in text?
Paste the text into the Input Text box. Each & becomes &, each < becomes <, each > becomes >, and quotes become " and '. The escaped version appears in the Result box. Copy it into your HTML and the browser will show the original characters instead of treating them as markup.
What is the difference between text to HTML and HTML to text?
This tool encodes: it turns special characters into entities so they display safely on a page. HTML to Text does the reverse job, deleting tags and decoding entities such as &, < and " to leave plain words. Use this one before publishing, the other when extracting.
Why are quotation marks converted too?
So the result is also safe inside an attribute value. A stray " in alt="..." or a ' in title='...' would end the attribute early and break the tag. As " and ' they display as normal quote marks, both in page text and in attributes.
Does it add <p> and <br> tags to my text?
No. It only escapes characters; line breaks stay as line breaks and no paragraph tags are added. For code or text where the line breaks should show, place the result inside a <pre> element, which displays line breaks as they are.
Will escaping the same text twice cause problems?
Yes. The second pass escapes the ampersands from the first, so < becomes &lt; and the page shows < instead of <. If your source already contains entities, decode it first or escape only the original text once.
Is my text sent to a server?
No. The five replacements run in your browser tab, so code, internal URLs or private messages you paste never leave your device. Nothing is saved after you close the page.
This tool runs entirely in your browser. What you enter or upload stays on your device and is never sent to our servers.