New Line To BR

Add an HTML line-break tag in front of every newline so plain text keeps its line structure when pasted into HTML.

  • Runs in your browser
  • Free, no sign-up
Ctrl + Enter also runs the tool

What this tool gives you

PHP-compatible

Same behaviour as nl2br(): the tag is inserted and the original newline is kept.

HTML or XHTML

Switch between <br> and <br /> with one checkbox.

Live preview

See the converted markup immediately.

Frequently asked questions

Why is the newline kept after the <br>?

That is how PHP nl2br works and it keeps the HTML source readable. Browsers ignore the plain newline, so the rendering is identical.

Should I use <br> or <p>?

Use <br> for line breaks inside one paragraph, such as addresses or poetry. Separate paragraphs belong in their own <p> elements.

Does it escape HTML characters?

No. If the text contains < or &, run it through the HTML Encode tool first, then convert the newlines to <br>.

Does it handle Windows line endings?

Yes. \r\n, \n and \r are all recognised, so text from any operating system converts correctly.

From APIVoid

Need security checks inside your own product?

APIVoid turns the lookups you run here into developer-friendly JSON APIs: IP reputation, URL status and redirects, DNS lookups, SSL info, domain age, screenshots and much more. Simple pricing, 30-day free trial.