consolelog.tools

Line Break Converter

Convert line endings between LF, CRLF, CR — plus escape to literal \\n, unescape, and HTML <br>, with final-newline control. Live.

About this ToolHow it works, benefits & use cases

Line endings cause more trouble than they should — a file authored on Windows (CRLF) breaks a shell script on Linux (LF), and a stray classic-Mac CR throws off a diff. This converter normalizes line breaks between LF (\n), CRLF (\r\n), and CR (\r), and goes further: it can escape real breaks into the literal two-character \n for embedding in JSON or single-line config values, unescape literal \n back into real breaks, or turn breaks into HTML <br> tags. As you type it detects the current ending, flags when a file has mixed endings, and tells you whether the text ends with a final newline. A final-newline control lets you keep, add, or remove the trailing newline. Conversion happens live in the browser, the input state is captured in a shareable URL, and your text is never uploaded.

How to Use

  1. 1Paste your text into the input panel, or click "Load example" to try mixed line endings.
  2. 2Read the detection strip: it names the current ending, warns if endings are mixed, and shows whether the text ends with a newline.
  3. 3Choose a target from "Convert to" — LF, CRLF, CR, escaped \n, unescaped, or HTML <br> — or use the quick "To Unix" / "To Windows" buttons.
  4. 4For LF/CRLF/CR/unescape targets, set the "Final newline" option to keep, add, or remove the trailing newline.
  5. 5Click Convert, then copy or download the result, or share the URL to hand the exact input to someone else.

Key Benefits

  • Converts between LF, CRLF, and CR by normalizing first, so any mix of endings is handled cleanly
  • Escape to literal \n for JSON / CSV / single-line configs, plus the inverse unescape
  • Render line breaks as HTML <br> tags in one step
  • Live detection of the current ending, with a clear "mixed line endings" warning
  • Shows whether the text has a final newline and lets you keep, add, or remove it
  • Per-ending counts (total breaks, LF, CRLF, CR) update as you edit
  • Shareable URL captures the input and settings; everything runs in your browser

Common Use Cases

  • Fixing CRLF/LF mismatches before committing files to a Git repository
  • Normalizing a config or script that was edited across Windows and Linux machines
  • Escaping a multi-line snippet into a single \n-delimited string for JSON or an env var
  • Converting plain text into <br>-separated HTML for an email or template
  • Adding or stripping a trailing newline to satisfy a linter or POSIX file expectation

0 characters · live

Enter text above to see the converted output.

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools