How to use the text to html converter
- Open your .txt file in any editor, select everything and paste it into the Plain text box.
- Choose a structure: paragraphs, one paragraph per line, line breaks only, or preformatted text.
- Leave link detection on if you want URLs and email addresses to become clickable, and tick the full page option if you need a standalone file.
- Copy the HTML from the result box and paste it into your page, CMS or email template.
Change text to HTML: what the converter does
To change text to html you have to do three jobs: mark where blocks of text start and end, make sure characters like < and & do not get read as markup, and optionally turn web addresses into links. This converter does all three in one pass, so a text file to html conversion that used to need a search and replace script takes one paste.
Nothing is guessed about fonts or colours. A plain text file carries no formatting, so the output is clean semantic markup that picks up the styles of whatever page you put it in.
Converting text to HTML: paragraphs, line breaks and pre
Converting text to html starts with the structure choice, because browsers collapse whitespace and ignore newlines in normal text. The four modes handle that in different ways.
| Mode | Blank line | Single line break | Best for |
|---|---|---|---|
| Paragraphs | Ends a <p> | <br> inside the paragraph | Articles, emails, notes |
| One paragraph per line | Ignored | Starts a new <p> | Lists of statements |
| Line breaks only | Extra <br> | <br> | Poems, addresses, signatures |
| Preformatted | Kept | Kept | Logs, code, aligned columns |
Leading and trailing spaces on each line are trimmed in the first three modes, because HTML would collapse them anyway. Preformatted mode keeps every space and newline exactly.
Convert a text file to HTML safely
To convert text file to html without breaking the page, every special character is escaped: & becomes &, < becomes <, > becomes > and double quotes become ". A line such as if (a < b && c) therefore shows up as text instead of opening a tag, and a pasted <script> is displayed rather than run.
If your target system is not UTF-8, switch non-ASCII characters to numeric entities: the letter e with an acute accent becomes é and the euro sign becomes €. For escaping rules in more detail, see the HTML escape tool.
Convert a text document to HTML: links and full pages
When you convert text document to html, addresses that start with http://, https:// or www. become anchors, and plain addresses like name@example.com become mailto: links. A trailing full stop, comma or closing bracket that belongs to the sentence is left outside the link, but a bracket that is part of the address, as in a Wikipedia URL, stays inside it. Ampersands in query strings are escaped in the href the way the specification requires.
Tick the full page option to get a complete document with <!DOCTYPE html>, a UTF-8 charset declaration, a viewport meta tag and your title, ready to save as an .html file. To control link attributes such as rel and target, build the tag with the HTML link generator.
Rich text to HTML: what this tool does not do
This tool starts from plain text. If you copy from Word or Google Docs, the browser flattens bold, italics, headings and lists to bare text when you paste into the box, so those styles are lost. Rich text to html conversion needs a source that still carries the formatting.
Two routes keep it: write the document in Markdown and use the Markdown to HTML converter, or paste into a rich editor and read its source view. To go the other way, the HTML to text tool strips markup back out.
Common problems and how to avoid them
Text that looks fine in the editor but runs together in the browser nearly always lacks block structure: use the paragraph mode for prose. Columns of aligned numbers collapse into single spaces unless you choose preformatted.
- Smart quotes and dashes from a word processor are kept as typed. They are fine in UTF-8 pages.
- Tabs are not converted into table cells. Use the text to table converter for tabular data.
- Very long unbroken strings, such as base64 blobs, will not wrap on narrow screens unless you add a CSS rule like
overflow-wrap: anywhere.
Worked examples
| Example | Input | Result |
|---|---|---|
| Notes with a link | Plain text: Hello team, / the draft is at www.example.com/draft. / Thanks!; Structure: paragraphs; Link URLs and email addresses: yes; Non-ASCII characters: keep; Wrap in a full HTML page: no; Page title: Notes | <p>Hello team,<br> / the draft is at <a href="https://www.example.com/draft">www.example.com/draft</a>.</p> / <p>Thanks!</p> |
| One paragraph per line | Plain text: First point / Second point / Third point; Structure: lines; Link URLs and email addresses: yes; Non-ASCII characters: keep; Wrap in a full HTML page: no; Page title: List | <p>First point</p> / <p>Second point</p> / <p>Third point</p> |
| Poem with line breaks | Plain text: Roses are red, / Violets are blue. / A < B & C; Structure: br; Link URLs and email addresses: no; Non-ASCII characters: keep; Wrap in a full HTML page: no; Page title: Poem | Roses are red,<br> / Violets are blue.<br> / <br> / A < B & C |
| Full page, ASCII-safe | Plain text: Café menu / Crème brûlée 6€; Structure: paragraphs; Link URLs and email addresses: yes; Non-ASCII characters: numeric; Wrap in a full HTML page: yes; Page title: Menu | <!DOCTYPE html> / <html lang="en"> / <head> / <meta charset="utf-8"> / <meta name="viewport" content="width=device-width, initial-scale=1"> / <title>Menu</title> / </head> / <body> / <p>Café menu</p> / <p>Crème brûlée 6€</p> / </body> / </html> |
FAQ
How do I convert a text file to HTML?
Open the .txt file, copy its contents, paste them into the box and copy the generated HTML. Choose the full page option if you want a complete .html document to save.
Does it keep line breaks and blank lines?
Yes. In paragraph mode a blank line starts a new paragraph and a single line break becomes a br tag. Preformatted mode keeps every space and newline exactly.
Can it turn rich text into HTML?
Not from the clipboard: pasting into a text box removes bold, italics and headings. Write Markdown and use the Markdown to HTML converter, or copy the source view of a rich editor.
Are special characters escaped?
Yes. Ampersands, angle brackets and double quotes are converted to entities, so pasted code or markup is shown as text and cannot inject elements into your page.
Which links are detected?
Addresses beginning with http://, https:// or www., and plain email addresses. Punctuation at the end of a sentence stays outside the link.
Is my text uploaded?
No. The conversion runs in your browser, so the text file contents stay on your device.
Sources and references
- The p element, MDN Web Docs: paragraph markup
- Character reference, MDN Web Docs: why special characters are escaped