Test files › Documents › line-endings-lf.txt

Text file with LF line endings

20 lines terminated with Unix LF (\n). Byte-for-byte content twin of the CRLF file.

↓ Download line-endings-lf.txt
Filenameline-endings-lf.txt
FormatTXT
Size1.0 KB (1,051 bytes)
MIME typetext/plain; charset=utf-8
SHA-256a6ef6400340b1a434b5d8eb8527e5ee71cf2eefff19135dab9f2b726c390df07
What this file catchesThe control half of the CRLF comparison.

Handle it in code

Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.

Python

Read the bytes, not text mode, so the line endings survive to be counted. Invisible format characters (category Cf: zero-width spaces, direction overrides, the BOM) are the ones that make two identical-looking strings compare unequal.

import unicodedata

with open("line-endings-lf.txt", "rb") as f:
    data = f.read()
crlf = data.count(b"\r\n")
lf, cr = data.count(b"\n") - crlf, data.count(b"\r") - crlf
print(f"line endings: {crlf} CRLF, {lf} LF, {cr} bare CR")
print("ends with a newline" if data.endswith(b"\n") else "no newline at the end of the file")
text = data.decode("utf-8")
print(f"longest line: {max(map(len, text.splitlines()), default=0):,} characters")
hidden = sorted({f"U+{ord(c):04X} {unicodedata.name(c, '?')}" for c in text if unicodedata.category(c) == "Cf"})
print("invisible characters:", ", ".join(hidden) if hidden else "none")

Run against this file, it prints: line endings: 0 CRLF, 20 LF, 0 bare CR ends with a newline longest line: 52 characters invisible characters: none

Related guides and tools

Sample TXT and encoding test filesCharacter encodingsVerify its SHA-256

Download & verify

curl -fsSL -o "line-endings-lf.txt" "https://files.hexaqa.com/text/line-endings-lf.txt"
curl -fsSL "https://files.hexaqa.com/text/line-endings-lf.txt" | sha256sum # expect: a6ef6400340b1a434b5d8eb8527e5ee71cf2eefff19135dab9f2b726c390df07

More documents test files

valid-1page.pdfvalid-500pages.pdflatin1.txtline-endings-crlf.txtno-trailing-newline.txtutf16be.txtutf16le.txtutf8-no-bom.txt

← All Documents files