Loading…

How to use Newline to BR Converter

Paste plain text with line breaks, and the tool converts each break into an HTML <br> tag — toggle XHTML mode for self-closing tags, or reverse the conversion.

Frequently asked questions

What does nl2br do?

It replaces every newline character (\n, \r or \r\n) in your text with an HTML <br> tag so line breaks survive when the text is rendered inside HTML, mirroring PHP's nl2br() function.

What is XHTML mode?

XHTML and self-closing HTML require void elements to be closed, so XHTML mode outputs <br /> with a trailing slash instead of <br>. Standard HTML5 accepts either form.

Can it convert <br> back to newlines?

Yes, switch to reverse mode to turn <br>, <br/> and <br /> tags back into plain newline characters, which is handy when cleaning HTML into editable plain text.

More HTML Tools

Text/SVG to Data URI
Encode text, SVG or CSS into a base64 or URL-encoded data URI you can embed inline in HTML or CSS with no external file
Meta Tag Generator
Generate complete SEO meta tags including title, description, Open Graph, and Twitter Cards
Open Graph Generator
Generate Open Graph and Twitter Card meta tags for social media sharing optimization
HTML Table Generator
Generate semantic HTML tables from rows and columns input with customizable styling
HTML List Generator
Generate ordered or unordered HTML lists from text input with proper markup structure
HTML Color Code Generator
Generate HTML color code snippets in hex, RGB, RGBA, and HSL formats with examples
HTML Link Generator
Generate anchor tag with href, target, rel, title and all link attributes configured
HTML Image Tag Generator
Generate img tag with src, alt, width, height, srcset, loading and all image attributes
HTML Button Generator
Generate styled HTML button code with classes, attributes, and event handlers
iFrame Generator
Generate iframe embed code with src, width, height, sandbox, and all iframe options
HTML Input Generator
Generate form input fields with labels, types, validation, and accessibility attributes
Schema.org JSON-LD Generator
Build schema.org structured data JSON-LD for Article, Product, FAQPage, LocalBusiness, Organization and BreadcrumbList

← View all HTML ToolsBrowse all 1,100+ tools →