Skip to content

HTML and Text Converter

Mode
Converted result
—

Pick Text to HTML to wrap your text in p tags, add br at single line breaks and escape the five special characters, so Fish & chips becomes Fish & chips. Pick HTML to text to remove tags, scripts and comments and decode references like   back into plain characters.

About this tool

Pasting a product note into a CMS source view, or copying text out of an email template, both run into the same snag: markup and plain text use different rules for the ampersand, the angle brackets and line breaks. This converter works both ways. Text to HTML escapes every special character and turns empty lines into separate paragraphs, ready to paste into a template. HTML to text drops the tags, throws away script and style blocks, keeps list items on their own lines with a dash, and decodes named and numeric character references. Everything runs in your browser; the markup is never sent anywhere. One limit: it is a cleaner, not a full browser engine, so CSS that hides elements is ignored and their text still appears.

How to use it

  1. Pick a direction

    Choose Text to HTML or HTML to text at the top of the widget.

  2. Paste or open a file

    Paste into the box, or open a .txt or .html file from your device; it is read locally.

  3. Copy the result

    The converted markup or text appears in a code box as you type; use its Copy button.

Examples

A price line with & and <

Mode
Text to HTML
Plain text
Fish & chips < £5

Result Converted result: <p>Fish & chips < £5</p>

  1. Escaped & as &, < as <, > as >, " as " and ' as '.
  2. Split at blank lines into 1 paragraph(s); each wrapped in <p>, single line breaks became <br>.

The ampersand and the less-than sign would break the markup, so they become & and <; the pound sign is left as it is.

A paragraph with entities

Mode
HTML to text
HTML markup
<p>Tom & Jerry <3</p>

Result Converted result: Tom & Jerry <3

  1. Removed comments plus script, style and head blocks, then 2 tag(s).
  2. Block tags and <br> became line breaks, list items start with "- ", and character references such as & were decoded.

Both tags go, and &,   and < turn back into the characters they stand for.

A menu note with two paragraphs

Mode
Text to HTML
Plain text
Fish & chips: £5 Peas < £1 Open 12–2pm

Result Converted result: <p>Fish & chips: £5<br>
Peas < £1</p>
<p>Open 12–2pm</p>

  1. Escaped & as &, < as <, > as >, " as " and ' as '.
  2. Split at blank lines into 2 paragraph(s); each wrapped in <p>, single line breaks became <br>.

The empty line splits the note into two p elements, the single break becomes br, and & and < are escaped so the markup stays valid.

How it is calculated

Text to HTML: & → &, < → <, > → >, " → ", ' → '; blank line = new p element. HTML to text: tags removed, character references decoded per the WHATWG named references table

In Text to HTML mode the input is split at empty lines. Each block becomes one p element, and a single line break inside a block becomes a br. Before wrapping, each line is escaped using the WHATWG serialization rules, plus quote escaping so the output is also safe inside attributes. In HTML to text mode, comments and script, style, head and template blocks are removed with their content. Runs of whitespace collapse to one space, as a browser renders them. Block tags such as p, div, headings and table rows become line breaks, li starts a line with a dash, and table cells are separated by tabs. Finally named references such as — and numeric ones such as × or = are decoded.

Sources

Use from code or an AI agent Free API · MCP

The same calculation is a free JSON API. No key needed. The answer is in result.stats.primary.

curl -X POST https://api.tools-directory.workers.dev/v1/tools/html-and-text-converter \
  -H 'Content-Type: application/json' \
  -d '{"inputs":{"mode":"to_html","text":"Fish & chips < £5"}}'

When not to use it

  • Rich formatting such as bold, links or headings is not created from plain text; only paragraphs and breaks are.
  • Pages built by JavaScript need a real browser; this reads only the markup you paste.
  • Sanitizing untrusted HTML for display on a site calls for a dedicated sanitizer library, not text extraction.

Common mistakes

  • Pasting already escaped text into Text to HTML, which turns & into &amp;.
  • Expecting a single line break to start a new paragraph; leave an empty line instead.
  • Forgetting that text hidden with CSS display none still appears in the plain text output.

Frequently asked questions

Is there an HTML to text editor that keeps line breaks?

Yes. In HTML to text mode, p, div, headings and table rows each end a line, br becomes a line break and every li starts a new line with a dash. Extra blank lines are trimmed to one, so the output reads like the page did, without any tags left behind.

How can I view HTML as plain text, like a text viewer?

Paste the source into HTML to text. The result box shows only what a reader would see: tags, comments, scripts and styles are gone, and entities such as © or — appear as the real symbols. It is a quick way to read an email template or a saved page without opening it in a browser.

How do I turn text into HTML code?

Choose Text to HTML and paste your text. Each block separated by an empty line becomes a p element, single breaks become br, and the characters &, less-than, greater-than and both quote marks are escaped. Copy the code box and paste it into your page source or CMS HTML view.

Can I convert a text file to HTML?

Use Open a text file in Text to HTML mode to load a .txt or .md file; it is read inside your browser and never uploaded. The output is a body fragment of p elements, so paste it between the body tags of a page and save that as a .html file.

Does this work like the Html to text action in Power Automate?

It follows the same idea: tags are dropped and the readable text is kept. It is handy for checking what an Outlook email body will look like after that flow step, or for cleaning one message by hand. It is a web page, not a connector, so it cannot run inside a flow.

Cite this tool

Using this tool in an assignment, article or report? Copy a citation, or a link for your website.

APA

Tools Directory Editorial Team. (2026, December 2). HTML and Text Converter. Tools Directory. Retrieved December 4, 2026, from https://directory.milunir.com/text-tools/text-editors/html-and-text-converter/

MLA

Tools Directory Editorial Team. “HTML and Text Converter.” Tools Directory, 2 Dec. 2026, https://directory.milunir.com/text-tools/text-editors/html-and-text-converter/. Accessed 4 Dec. 2026.

Chicago

Tools Directory Editorial Team. “HTML and Text Converter.” Tools Directory. Last modified December 2, 2026. Accessed December 4, 2026. https://directory.milunir.com/text-tools/text-editors/html-and-text-converter/.

Link<a href="https://directory.milunir.com/text-tools/text-editors/html-and-text-converter/">HTML and Text Converter – Tools Directory</a>