How to use the newline to BR converter
- Paste your text into the Text box.
- Choose the Direction: New lines →
<br>or<br>→ new lines. - For new lines to
br, set the options: XHTML style<br />, Escape HTML in the text first (on by default) and Blank lines start new<p>paragraphs. - Copy the HTML. A Preview below it shows how the browser will display it.
What it does and when to use it
Text from a form, a spreadsheet cell or a plain-text email keeps its line breaks only as invisible characters. Put it into a web page and everything runs together on one line. This tool adds explicit breaks, so a delivery address, a recipe step list, song credits or a short message keeps its shape.
The reverse direction is for text going the other way: copying content out of a CMS or an HTML email into a text field, a CSV or a chat, where <br> would show up as literal tags. For a full conversion of HTML with paragraphs and lists, use HTML to Text. If the text contains characters you want to see as codes, the HTML Encoder shows the escaped form on its own.
How it works
With escaping on, &, <, >, " and ' are replaced by their HTML entities first. Then each line ending, \n or \r\n, gets a <br> (or <br />) placed in front of it. In paragraph mode the text is split at blank lines, each block is trimmed and wrapped in <p>…</p>, and single line breaks inside a block become br tags. The br to new line mode replaces every <br>, <br/> or <BR /> and a line break right after it with one new line. It all runs in your browser.
Worked examples
An address with a blank line. The sample gives:
Asha Rao<br>
42 Lake View Road<br>
Bengaluru 560001<br>
<br>
Thanks for your order!
Paragraphs and XHTML. Tick both options and the same text becomes two paragraphs:
<p>Asha Rao<br />
42 Lake View Road<br />
Bengaluru 560001</p>
<p>Thanks for your order!</p>
Escaping. The two lines Use <b> for bold and and & for and become Use <b> for bold<br> and and & for and, so the page shows the tag name as text instead of turning the rest bold.
Back to new lines. Line one<br />, a new line, then Line two<BR>Line three gives three plain lines.
Limits and tips
- Spaces are not changed. Several spaces in a row still collapse to one in the browser; use a
preelement if the spacing matters. - In paragraph mode, a line with only spaces counts as blank.
- For many short lines that form a list, a real list is better for screen readers. Build one with the HTML List Generator.
Frequently asked questions
Why do my line breaks disappear in HTML?
Is this the same as PHP nl2br?
Should I use br tags or paragraphs?
When should I turn off "Escape HTML in the text first"?
Does br to new lines also remove other tags?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.