Skip to main content

Line Ending Converter Convert between line endings: LF (Unix), CRLF (Windows), CR (Classic Mac).

Line Ending Converter illustration
📝

Line Ending Converter

Convert between line endings: LF (Unix), CRLF (Windows), CR (Classic Mac).

1

Paste Text

Paste text with line endings to convert.

2

Select Target Line Ending

Choose the target line ending: LF, CRLF, or CR.

3

Copy Converted Text

Copy the text with converted line endings.

Loading tool...

What Is Line Ending Converter?

A Line Ending Converter is a utility that changes the line break characters in text between the three major formats: LF (\n, used by Unix/Linux/modern macOS), CRLF (\r\n, used by Windows), and CR (\r, used by Classic Mac OS). Developers working on cross-platform projects use it to fix compatibility issues when moving code or data between operating systems. One specific problem it solves is the inconsistent line breaks that occur when transferring text files from a Windows system to a Unix-based system, which can lead to formatting errors or compilation issues.

The tool normalizes all line endings to LF before converting to the target format, ensuring consistency in the output. This process involves replacing CRLF and CR characters with LF using regular expressions, as seen in the code's `onProcess` function. What makes this tool different is its ability to convert between these formats using a simple radio button selection, allowing users to choose from LF, CRLF, or CR targets.

It also provides an input field for pasting text and an output label to display the converted text, making it easy to use for tasks like crlf to lf or lf to crlf conversions. By providing this functionality, the tool helps resolve common issues with line endings, such as fixing crlf line endings in code files, and can be used as a newline converter or line break converter for various text processing needs, including how to convert line endings in different operating systems.

Why Use Line Ending Converter?

  • Fix line ending issues when moving files between OS platforms
  • Standardize line endings for cross-platform projects
  • Convert Windows CRLF to Unix LF or vice versa
  • Resolve Git and version control line ending conflicts

Common Use Cases

Cross-platform Development

Normalize line endings when collaborating across Windows, Mac, and Linux.

Git Issues

Fix line ending conflicts in version-controlled files.

File Transfer

Convert line endings after transferring files between operating systems.

Script Compatibility

Ensure shell scripts use LF line endings for Unix compatibility.

Technical Guide

The converter uses a two-step process. First, all line endings are normalized to LF (\n) by replacing CRLF (\r\n) first, then replacing any remaining CR (\r). CRLF must be replaced first to prevent creating double LF. After normalization, the tool converts LF to the target format: for CRLF, LF becomes \r\n; for CR, LF becomes \r; for LF, no further conversion is needed. This approach handles mixed line endings in the input correctly, producing consistent output regardless of the input format.

Tips & Best Practices

  • 1
    LF (\n) is the standard for Unix, Linux, and modern macOS
  • 2
    CRLF (\r\n) is the standard for Windows
  • 3
    CR (\r) was used by Classic Mac OS 9 and earlier
  • 4
    Most modern editors handle both LF and CRLF, but scripts may require specific endings

Related Tools

Frequently Asked Questions

Q What is the difference between LF and CRLF?
LF (Line Feed, \n) is one character. CRLF (Carriage Return + Line Feed, \r\n) is two characters. They serve the same purpose on different OS.
Q What line ending format should I use?
Use LF for Unix/Mac/modern systems. Use CRLF for Windows-specific applications. Most modern software handles both.
Q Can it handle mixed line endings?
Yes, all line endings are normalized first, then converted to the target format.
Q Does converting line endings change how the text looks?
Visually the text looks identical. The change is in the invisible line break characters.
Q How do I know which line endings my text has?
Use the Whitespace Visualizer tool to see line ending characters marked with ↵ (LF), ¶ (CRLF), or ← (CR).

About This Tool

Line Ending Converter is a free online tool by FreeToolkit.ai. All processing happens directly in your browser — your data never leaves your device. No registration or installation required.