OnlineTextLab
Esc

Text to HTML Converter

Wrap plain text in correct HTML, with paragraphs, line breaks, simple lists and links, and everything risky escaped.

The HTML appears here as you type.

Options
A single line break becomes

Runs on your device. Your files and text are not uploaded.

About Text to HTML

Plain text does not display properly on a web page. Paste a few paragraphs into a template and the line breaks vanish, and a stray < can swallow half the sentence after it. This tool makes the small, boring conversion correctly: blank lines become paragraphs and reserved characters become entities.

It is meant for text that was never written with markup in mind, such as an email you want to post as an announcement, notes from a text editor, terms and conditions from a colleague, or a support reply going into a help center. No syntax is needed, and characters like asterisks are left exactly as typed.

That is the main difference from Markdown to HTML. If your text uses bold or # headings on purpose, use that page. Here they would stay as literal characters, which is what you want when an asterisk really is an asterisk.

How it works

The text is split on blank lines into blocks, and spaces at the start and end of each line are removed. A block becomes a list if every one of its lines starts with - , * or •, or with a number followed by . or ). Otherwise it becomes a paragraph. A block with one bullet line among ordinary sentences stays a paragraph, so a sentence starting with a dash is not mistaken for a list.

The characters &, <, > and " are converted to entities before any tags are added, so nothing you paste can act as markup. A script tag in your text ends up displayed as words. Apostrophes are left alone, because they are safe in element text and it keeps the result readable.

Addresses starting with http:// or https:// become links. Trailing punctuation such as the full stop at the end of a sentence stays outside the link. Addresses with other schemes, like javascript:, and text like www.example.com with no scheme remain plain words.

How to use Text to HTML

  1. Paste your text into the left pane, use Open file for a .txt file, or press Try an example.
  2. Check the source on the right, and use the Preview tab to see it rendered.
  3. Open Options to choose what a single line break becomes, and to switch list or link detection off.
  4. Press Copy result, or use Download .html.

An office note with an ampersand, a list and a link

Input
Lunch is at 1 pm & cake follows.
Bring a plate.

- Sandwiches
- Fruit

Map: https://example.com/map.
Output
<p>Lunch is at 1 pm &amp; cake follows.<br>
Bring a plate.</p>
<ul>
<li>Sandwiches</li>
<li>Fruit</li>
</ul>
<p>Map: <a href="https://example.com/map">https://example.com/map</a>.</p>

The single line break inside the first block became a <br>, the ampersand was escaped, and the final full stop stayed outside the link.

When it helps

  • Posting an announcement written in an email into a CMS field that expects HTML.
  • Formatting a plain text policy or set of terms for a web page without retyping it.
  • Preparing user-written text for a template, where a stray < must not break the layout.
  • Filling the HTML part of an email from a plain text version you already have.

Tips for a better result

  • Choose A new paragraph for single line breaks if your text has one sentence or item per line. Keep A <br> tag for addresses, poems and signatures, where the lines belong together.
  • Text copied from a PDF often has a hard break at the end of every line, and each one will become a <br>. Rejoin those lines in your editor first.
  • Separate a list from the sentence that introduces it with a blank line. If they share a block, the block is no longer all bullets and stays a paragraph.

Good to know

  • It does not guess headings. A short line on its own becomes a paragraph, since there is no reliable way to know what you intended, so add heading tags yourself afterwards.
  • Nested lists are not detected, and indentation is removed. Use Markdown for those.
  • Text formatting like bold or italic cannot be expressed, because plain text has none. Copying from Word or a web page brings over only the words.
  • Links are only created for http and https addresses that are written out in full. Email addresses and bare domains stay as text.
  • Runs of spaces are kept in the source, but browsers display them as one. Aligned columns of text need a <pre> element or a table.

Questions people ask

Should a single line break be a br or a new paragraph?

It depends on what the break means. If lines belong to one thought, like a postal address, <br> keeps them together without spacing. If each line is its own statement, separate paragraphs give the normal space between them and are easier to style.

What happens if my text contains HTML tags?

They are escaped and displayed as visible text, not treated as markup. That is the point of this tool, since it is how you safely publish a sentence about <div> elements. To work with real HTML, try the HTML Beautifier.

Why are accented letters and emoji not turned into entities?

They do not need to be, as long as the page is served as UTF-8, which nearly all are. For a system that mangles them, run the result through the HTML Entity Encoder with the non-ASCII setting, but only on plain text and not on tags.

What to use next

Last reviewed . Read our editorial policy.