User Rating 0.0
Total Usage 0 times

      
Is this tool helpful?

Your feedback helps us improve.

About

Raw text pasted into a CMS or email template without proper HTML markup produces collapsed whitespace, dead links, and broken list structures. This converter parses plain text and emits semantic HTML: URLs and email addresses become clickable a elements, consecutive newlines become br tags, lines of three or more hyphens become hr elements, and indented lines prefixed with *, -, or digits resolve into properly nested ol and ul trees. The parser operates in a single pass with an indent-tracking stack, so arbitrarily deep mixed lists are handled without ambiguity. Note: the tool assumes a 2-space or 4-space indent unit for nesting depth calculation. Tabs are normalized to 4 spaces.

plain text to html text converter htmlize url detection nested lists text formatting html generator

Formulas

The converter applies a deterministic pipeline to transform each line of input. The line classification logic follows this precedence:

{
hr if match(line, /^-{3,}$/)ol if match(trimmed, /^\d+\.?\s+/)ul if match(trimmed, /^[*-]\s+/)text otherwise

For list nesting, indent depth d is computed as:

d = leadingSpaces(line)indentUnit

where indentUnit = 2 spaces (configurable). A stack S of tuples (depth, listType) governs open/close tag emission. When dcurrent > dprevious, a new nested list opens. When dcurrent < dprevious, lists are closed until stack depth matches.

URL detection uses the pattern: /(?:https?|ftp):\/\/[^\s<>]+|www\.[^\s<>]+/g. Email detection: /[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}/g. URLs within list item text and plain text lines are linkified after structural parsing is complete.

Reference Data

Plain Text PatternDetected AsHTML OutputNotes
https://example.comURL<a href="...">...</a>http and https supported
[email protected]Email<a href="mailto:...">...</a>Standard email pattern
Empty line (\n\n)Line break<br>Single newline also converts
---Horizontal rule<hr>3 or more hyphens, nothing else on line
1 Item textOrdered list<ol><li>...</li></ol>Digit + space(s)
1. Item textOrdered list<ol><li>...</li></ol>Digit + dot + space(s)
* Item textUnordered list<ul><li>...</li></ul>Asterisk + space(s)
- Item textUnordered list<ul><li>...</li></ul>Hyphen + space(s), but not ---
* NestedNested unorderedNested <ul> inside <li>2-space indent = 1 depth level
1. Deep nestedNested orderedNested <ol> inside <li>4-space indent = 2 depth levels (with 2-space unit)
Mixed: ul then ol childMixed nesting<ul><li>...<ol><li>...</li></ol></li></ul>List type tracked per depth level
Plain text lineTextText content (with <br> between lines)No special prefix detected
ftp://files.example.comURL<a href="...">...</a>ftp protocol also detected
www.example.comURL<a href="http://...">...</a>Auto-prefixed with http://

Frequently Asked Questions

The parser maintains an internal stack that tracks both the indentation depth and the list type (ol or ul) at each level. When a line's indent depth increases, a new child list of the appropriate type is opened inside the current <li>. When depth decreases, all intervening lists are closed. This means you can nest an ordered list inside an unordered list item and vice versa at arbitrary depths.
A line is classified as a horizontal rule only if it contains three or more hyphens and nothing else (after trimming whitespace). A line like "- Item text" has content after the hyphen-space sequence, so it is classified as an unordered list item. The rule check has higher precedence and is evaluated first, so "---" or "------" always become <hr> elements.
Yes. All plain text content is escaped before insertion: < becomes <, > becomes >, & becomes &, and quotes are escaped. This prevents accidental HTML injection. URLs and email addresses are extracted before escaping so their href attributes remain valid.
URL and email linkification is applied as a final pass on the text content of each line, after structural parsing (list/hr detection) is complete. This means a URL appearing inside a list item like "* Visit https://example.com today" will produce a proper <li> containing an tag wrapping only the URL portion.
The default indent unit is 2 spaces. All tab characters in the input are normalized to 4 spaces before processing, so one tab equals 2 nesting levels. If your text uses 4-space indentation for a single level, adjust the indent unit setting accordingly. The tool provides a configurable option for indent unit size.
Consecutive blank lines are collapsed into a single <br> tag. This prevents excessive vertical whitespace in the HTML output. A single blank line between text paragraphs also produces one <br>. If you need multiple line breaks, the generated HTML can be manually edited after conversion.