Text file guides

Normalize mixed line endings in a text file

·

A warehouse list can show four tidy lines on screen while using three different line-ending sequences on disk. Inspect the source bytes before changing a file for an importer or a shared Git repository.

Line Ending Converter

Count the three endings in the warehouse list

Save the mixed-ending warehouse sample and select Open Unicode text file. The four lines contain one CRLF, one LF and one CR. The last line contains Hebrew text and ends in the digit 3 with no line ending. The tool also reports a UTF-8 byte-order mark.

Expand Show source line endings to check the order of the markers. The display field can normalize original carriage returns. The marker preview and counts come from the imported file bytes.

Count the three endings in the warehouse list
TargetBytes in UTF-8 or ASCIICommon use
LF0AUnix-like systems and Git repositories configured for LF
CRLF0D 0ASome Windows programs and protocols
CR0DSome older text formats

Mixed-ending warehouse list with a UTF-8 BOMWHATWG text area API value and newline normalizationGit gitattributes text and eol attributes

Convert to LF and reopen the downloaded file

Choose LF, select Convert line endings and download the file. Open the download in the converter. It should show three LF endings, zero CRLF and CR, and Final line ending absent. Check that Café, the tabs and the Hebrew word still appear in the marked preview.

You can inspect the download with a hex editor. The first three bytes remain EF BB BF. The line separator bytes are now 0A. Opening the download here avoids changes the system clipboard can make to newline bytes.

Mixed-ending warehouse list with a UTF-8 BOMUnicode encoding forms and byte-order marks

Choose an ending that matches the destination

Use the exact line endings required by the receiving application. For a Git project, check the path’s text and eol attributes before normalizing it. A Windows editor can show a working tree with CRLF even when Git stores LF for that path.

For UTF-16 or UTF-32, use a source file with a byte-order mark. The download retains that encoding. With cleanup disabled, conversion replaces the three supported newline sequences. A Unicode line separator such as U+2028 stays as it was.

Git gitattributes text and eol attributesUnicode encoding forms and byte-order marks

Trim line ends and keep at most one blank line between records

Enable Trim trailing spaces and tabs to strip those specific characters at the end of a physical line. The leading indentation on a content line stays where it was. Review the download carefully when trailing spaces are meaningful, such as at the end of a Markdown line.

Enable Limit consecutive blank lines and choose 1 to keep at most one per run. A blank line has only ASCII spaces or tabs, or no characters. Choose 0 to remove every such record. Disable both switches when the only requested change is CRLF, LF or CR.

Mixed-ending warehouse list with a UTF-8 BOMGit gitattributes text and eol attributes

Common questions

Can I keep the last line unterminated?

Yes. With the cleanup switches off, only the format of an existing final newline changes. Reopen the download and check Final line ending to verify it.

Why does Lines differ from the number of ending sequences?

A final line without a separator counts as a line. A final separator terminates its line without adding an extra empty row to the counter.

Sources

Put it into practice.

Related guides