Text file line endings: LF, CRLF, and CR

Line endings are control characters that separate text lines. They are usually invisible in an editor, but different conventions affect comparisons, version-control diffs, and scripts.

Common line-ending sequences

These are byte or code-point sequences, not visible punctuation in the rendered text. UTF-8 encodes LF and CR as single bytes, but other file encodings have different byte representations.

Mixed endings and final newlines

A file may contain more than one kind of separator, often after being edited by tools with different defaults. A final line terminator is separate from the choice of separator between lines: a file can end with a newline or omit it. Some line-counting commands count terminator characters, so the last unterminated line may not be included in a newline count.

TinyDevTools behavior

The five text tools split on CRLF or LF and join output lines with LF. They do not split on lone CR, preserve a source file's encoding, or provide line-ending selection. This is suitable for quick pasted-text operations, not a replacement for a file converter.

Choosing a repository convention

Projects can document line-ending expectations and use a repository-level .gitattributes rule to normalize text files. Choose rules based on the consumers of those files; shell scripts, generated artifacts, and Windows-specific formats can have different requirements. Review the resulting diff after changing repository settings.

Read the CRLF vs LF guide →

For practical normalization tradeoffs, see how the line tools handle pasted input.

Advertisements