Trim & Clean
What It Does
Converts all line endings in your text to a single consistent style (LF, CRLF, or CR).
How to Use
- Paste text that may have mixed line endings (common when combining text from Windows and Unix).
- Select the target line-ending format from the dropdown.
- Click “Normalize”.
- Copy the result with consistent line endings.
Options Explained
| Option | Description |
|---|---|
| LF (\n) | Unix/macOS style — recommended for most uses |
| CRLF (\r\n) | Windows style |
| CR (\r) | Legacy Mac style (rarely needed) |
About Normalize Line Endings
The Normalize Line Endings tool converts all line-break characters in your text to a single, consistent style. Operating systems historically use different newline conventions: Unix, Linux, and macOS use LF (line feed, \n), Windows uses CRLF (carriage return plus line feed, \r\n), and classic Mac OS used CR (carriage return, \r). When files are shared across platforms, mixed line endings can cause display problems, diff noise, and unexpected behavior in scripts and build tools.
Inconsistent line endings are a frequent source of frustration in collaborative software development. Version control systems like Git may flag entire files as changed when only the line endings differ. Shell scripts with CRLF endings fail on Linux with cryptic errors. Build tools and linters can produce false warnings. Converting all line endings to a uniform style before committing code or sharing files eliminates these cross-platform compatibility issues.
Common Use Cases
- Converting Windows CRLF files to Unix LF for Linux servers
- Standardizing line endings before committing code to Git
- Fixing shell scripts that fail due to hidden carriage return characters
- Preparing text files for cross-platform distribution
- Cleaning up files transferred between macOS, Windows, and Linux
- Resolving diff noise caused by mixed line endings in code reviews
What Are Line Endings?
Line endings (also called newlines or end-of-line characters) are invisible control characters that mark where one line of text ends and the next begins. The three main conventions are LF (Line Feed,\n, used by Unix, Linux, and modern macOS), CRLF (Carriage Return + Line Feed, \r\n, used by Windows), and CR (Carriage Return, \r, used by classic Mac OS before OS X). When files are transferred between operating systems or edited by different tools, they can end up with a mix of all three styles, causing parsing errors, broken shell scripts, and noisy diffs in version control.
Frequently Asked Questions
Which line ending should I use?
LF (\n) is the most widely compatible choice and is recommended for most use cases, including Git repositories and Linux/macOS systems. Use CRLF only if you specifically need Windows-style line endings.
Why does my shell script fail with “\r: command not found”?
This error occurs when a script has CRLF line endings but is run on a Unix system. The carriage return character (\r) is interpreted as part of the command. Convert the file to LF line endings to fix it.
Does Git handle line endings automatically?
Git can convert line endings via the core.autocrlfsetting, but this only affects working copies. For consistent results, normalize line endings before committing and use a.gitattributes file to enforce a standard.
Is my text sent to a server?
No. All processing happens locally in your browser. Your text is never transmitted or stored.
This tool processes your text entirely in your browser. No data is sent to any server, ensuring complete privacy for sensitive or confidential content.