Sample TXT File Download
Need a sample TXT file to test an upload form, a text editor, or a script that reads files? Samples Files has a set of free plain text test files that you can download right away, with no registration. Besides simple ASCII files, the set covers the problems that break real code: UTF-8 with and without a BOM, UTF-16, legacy Latin-1, Windows CRLF line endings, a large 15,000-line file, and an empty file. All files are scanned and verified.
For other formats, check out our selection of Document Files
Pick and Download a Free Sample TXT file
Sample1.txt
Lorem Ipsum Text – TXT / 4Kb
Description: A title and several long paragraphs of lorem ipsum in plain ASCII. Good for text viewers, word wrap, and word counts.
Sample2.txt
100 Employee Names List – TXT / 4Kb
Description: A numbered list of 100 fictional employee names, one per line. Use it to test reading a file line by line.
Sample3.txt
Climate Change Report – TXT / 4Kb
Description: A structured report with headings and nested, indented bullet lists. Useful for testing indentation and Markdown-like plain text.
Sample4-utf8-multilingual.txt
UTF-8 Multilingual Text – TXT / 2Kb
Description: Pangrams in 15 languages, including Arabic, Hebrew, Hindi, Chinese, Japanese and Korean, plus symbols, emoji, and a combining accent. Use it to test Unicode rendering and string handling.
Sample5-utf8-bom.txt
UTF-8 with BOM – TXT / 1Kb
Description: Starts with the byte order mark EF BB BF, like files saved by many Windows tools. Use it to check that your code strips the BOM.
Sample6-utf16le.txt
UTF-16 Little-Endian – TXT / 1Kb
Description: UTF-16 LE with a BOM (FF FE). Every ASCII character takes two bytes, so tools that assume UTF-8 treat it as binary.
Sample7-latin1.txt
ISO-8859-1 (Latin-1) Encoded – TXT / 1Kb
Description: Accented text in a legacy single-byte encoding. Reading it as UTF-8 raises a decode error or shows replacement characters.
Sample8-crlf.txt
Windows CRLF Line Endings – TXT / 1Kb
Description: Every line ends with CR LF (\r\n). Use it to catch the stray \r that appears when code splits lines on \n only.
Sample9-large.txt
Large Text File, 15,000 Lines – TXT / 942Kb
Description: 15,000 numbered lines (00001 to 15000). Use it for streaming reads, pagination, upload limits, and checking that line counts are exact.
Sample10-empty.txt
Empty File – TXT / 0 bytes
Description: A 0-byte file. Use it to test that uploads, parsers, and validations handle empty input without crashing.
What Is a Sample TXT File?
A TXT file is a plain text file: a sequence of characters with no formatting, fonts, or images. It opens in every operating system and editor, which makes it the simplest file you can create, share, or process. A sample TXT file is a ready-made text file with fake content that you use to test software or practice without using real documents.
Plain text looks simple, but it hides two details that cause many bugs: the character encoding (UTF-8, UTF-16, Latin-1, with or without a BOM) and the line endings (LF on Linux and macOS, CRLF on Windows). A TXT file does not record either one, so your code has to detect or assume them. The files on this page give you one known example of each case.
Common Developer Use Cases for TXT Test Files
1. File Upload Testing: Check that your upload form accepts .txt files, shows the right size, and rejects or accepts empty files on purpose. Use sample10-empty.txt for the 0-byte case and sample9-large.txt to test size limits and progress bars.
2. Encoding Detection and Conversion: Import sample4 to sample7 and confirm that every accented letter and emoji comes through unchanged. If you see é instead of é, or a decode error, your code is assuming the wrong encoding.
3. Cross-Platform Line Handling: Read sample8-crlf.txt on Linux and macOS and compare each line to an expected value. A trailing \r makes string comparisons fail and breaks shell scripts with errors like 'bad interpreter: /bin/bash^M'.
4. Search, Indexing, and NLP: Use the multilingual file to test full-text search, tokenizers, and string length. Emoji such as 👨👩👧 are several code points long, and é can be one code point or two, so counting characters is harder than it looks.
Which Sample TXT File Should You Use?
| File | Variant | Best for |
|---|---|---|
| sample1.txt – sample3.txt | Plain ASCII text | Upload forms, text viewers, word counts, a first file-read call |
| sample4-utf8-multilingual.txt | UTF-8, 15 languages + emoji | Unicode rendering, fonts, right-to-left text, string length bugs |
| sample5-utf8-bom.txt | UTF-8 with BOM | Files saved by Windows tools, BOM stripping, header matching |
| sample6-utf16le.txt | UTF-16 little-endian | Encoding detection, Windows exports, binary-vs-text checks |
| sample7-latin1.txt | ISO-8859-1 (Latin-1) | Decode errors, mojibake, legacy system imports, iconv |
| sample8-crlf.txt | Windows CRLF line endings | Line splitting, trailing \r bugs, cross-platform scripts |
| sample9-large.txt | Large, 15,000 numbered lines (942 KB) | Streaming reads, pagination, performance, upload size limits |
| sample10-empty.txt | Empty (0 bytes) | Edge-case validation, empty upload handling, divide-by-zero bugs |
How to Download, Inspect, and Read a TXT Test File
The examples below use standard command-line tools (file, iconv, od, wc), which are
preinstalled on macOS and most Linux distributions, plus Python and
JavaScript. The output shown is what you get with the files on this
page.
Step 1: Download the file
Click Download file next to any sample above, or fetch it from the command line. Each file has a stable direct URL, so you can also download it in a CI job.
# Download a single file
curl -O https://samples-files.com/samples/documents/txt/sample1.txt
# Download every encoding test file
curl -O https://samples-files.com/samples/documents/txt/sample4-utf8-multilingual.txt \
-O https://samples-files.com/samples/documents/txt/sample5-utf8-bom.txt \
-O https://samples-files.com/samples/documents/txt/sample6-utf16le.txt \
-O https://samples-files.com/samples/documents/txt/sample7-latin1.txt Step 2: Detect the encoding
file -i guesses the encoding from the content. To see a BOM
for certain, dump the first bytes.
$ file -i sample4-utf8-multilingual.txt sample6-utf16le.txt sample7-latin1.txt
sample4-utf8-multilingual.txt: text/plain; charset=utf-8
sample6-utf16le.txt: text/plain; charset=utf-16le
sample7-latin1.txt: text/plain; charset=iso-8859-1
# Look at the first bytes to spot a BOM
$ head -c 8 sample5-utf8-bom.txt | od -An -tx1
ef bb bf 55 54 46 2d 38
$ head -c 8 sample6-utf16le.txt | od -An -tx1
ff fe 55 00 54 00 46 00 Step 3: Convert to UTF-8
When you know the source encoding, iconv converts it to
UTF-8 without losing any characters.
# Convert Latin-1 and UTF-16 to UTF-8
$ iconv -f ISO-8859-1 -t UTF-8 sample7-latin1.txt > latin1-as-utf8.txt
$ iconv -f UTF-16 -t UTF-8 sample6-utf16le.txt > utf16-as-utf8.txt Step 4: Check line endings and line counts
cat -A shows invisible characters, so a Windows line ending
appears as ^M$. Note that wc -l counts newline
characters, so a file without a final newline reports one line fewer.
# Show line endings: ^M$ means CRLF, $ alone means LF
$ head -n 2 sample8-crlf.txt | cat -A
Windows Line Endings (CRLF)^M$
===========================^M$
# Convert CRLF to LF (use dos2unix if you have it)
$ sed 's/\r$//' sample8-crlf.txt > sample8-lf.txt
# Count lines
$ wc -l sample9-large.txt sample10-empty.txt
15000 sample9-large.txt
0 sample10-empty.txt Step 5: Read it in your code
Always pass the encoding explicitly in Python. Without it, Python uses the system default, so the same script can work on Linux and fail on Windows.
# 1. Wrong encoding: Latin-1 bytes are not valid UTF-8
try:
open("sample7-latin1.txt", encoding="utf-8").read()
except UnicodeDecodeError as e:
print(e) # 'utf-8' codec can't decode byte 0xe9 in position 195: invalid continuation byte
text = open("sample7-latin1.txt", encoding="latin-1").read() # correct
# 2. BOM: "utf-8" keeps it, "utf-8-sig" strips it
open("sample5-utf8-bom.txt", encoding="utf-8").readline() # '\ufeffUTF-8 with BOM\n'
open("sample5-utf8-bom.txt", encoding="utf-8-sig").readline() # 'UTF-8 with BOM\n'
# 3. UTF-16: the BOM tells Python the byte order
open("sample6-utf16le.txt", encoding="utf-16").readline() # 'UTF-16 LE Sample\n'
# 4. Line endings: text mode converts CRLF to \n, newline="" keeps it
open("sample8-crlf.txt").readline() # 'Windows Line Endings (CRLF)\n'
open("sample8-crlf.txt", newline="").readline() # 'Windows Line Endings (CRLF)\r\n'
# 5. Large file: iterate line by line instead of read()
with open("sample9-large.txt") as f:
print(sum(1 for _ in f)) # 15000
# 6. Empty file: make sure your code handles ""
print(repr(open("sample10-empty.txt").read())) # '' In the browser, use the built-in TextDecoder:
// Run in the browser console on this page
const res = await fetch("/samples/documents/txt/sample6-utf16le.txt");
const bytes = await res.arrayBuffer();
// TextDecoder strips the BOM and decodes the bytes you tell it to
console.log(new TextDecoder("utf-16le").decode(bytes).split("\n")[0]);
// "UTF-16 LE Sample"
// fatal: true throws instead of inserting U+FFFD replacement characters
const latin1 = await (await fetch("/samples/documents/txt/sample7-latin1.txt")).arrayBuffer();
try {
new TextDecoder("utf-8", { fatal: true }).decode(latin1);
} catch (e) {
console.log("Not valid UTF-8:", e.message);
} Download Best Practices
- Use the Download button, not copy and paste. Copying from the browser converts the text to your system's encoding and line endings, and drops the BOM, so the encoding test files lose exactly what they are meant to test.
- Don't open and re-save the test files. Many editors
silently convert the encoding or line endings on save. Check the file
with
file -iif a test suddenly passes. - Commit the files as test fixtures. Keep them in your
repository under a folder like
tests/fixtures/txt/so your tests don't depend on a network download. If you use Git, mark them with-textin.gitattributesso Git doesn't convert CRLF to LF. - Always specify the encoding when reading. Defaults differ between operating systems and language versions. Write UTF-8 and read with an explicit encoding.
- Test the edge cases, not just the happy path. Pair sample1.txt with the BOM, Latin-1, CRLF, and empty files so you know your code handles real-world input.
Other Sample Document files you may like
Sample CSV Files
Download sample CSV files from 10 to 10,000 rows for data import, analysis, and performance testing.
Sample JSON Files
Free sample JSON files for testing APIs, data import, and development projects with various data structures.
Sample PDF Files
Download sample PDF files for testing document viewers, uploads, and PDF processing tools.
More ideas for using a TXT file
1. Open Source Collaboration: Use TXT files to share code snippets, documentation, or project notes with open-source communities. Plain text ensures contributors can easily view, edit, and merge changes using virtually any platform or tool.
2. Educational Resources and Manuals: Develop simple yet effective study notes, quick-reference guides, or instructional materials in TXT format. Without any complex formatting, these files load quickly on any device and remain accessible to a wide audience.
3. Version Control and Rapid Prototyping: Store draft content or initial outlines for projects in TXT files, then track changes effortlessly using version control tools like Git. This approach simplifies collaboration and keeps the revision history transparent.
4. Data Logging and Configuration: Employ TXT files to record logs, system outputs, or configuration details. The plain-text nature makes them easy to parse programmatically, easing debugging and data analysis tasks.
5. Lightweight Note-Taking and Brainstorming: Maintain to-do lists, brainstorm sessions, or journal entries in TXT files. Their simplicity and small file size allow for swift editing, archiving, and sharing—perfect for capturing thoughts on the go.
Frequently Asked Questions About Sample TXT Files
What is a sample TXT file?
A sample TXT file is a ready-made plain text file with fake content. Developers, testers, and students use it to try out text editors, upload forms, parsers, and scripts without using real documents.
Are these sample TXT files free?
Yes. Every TXT file on Samples Files is free to download with no registration or sign-up, and you can use them in personal and commercial projects.
What encoding does a TXT file use?
A TXT file has no fixed encoding and does not store which one it uses. Most modern files are UTF-8, but Windows tools often write UTF-8 with a BOM or UTF-16, and older systems write ISO-8859-1 or Windows-1252. That is why this page includes one sample of each.
What is a BOM in a text file?
A byte order mark (BOM) is a short invisible sequence at the start of a file: EF BB BF for UTF-8 and FF FE for UTF-16 little-endian. It helps tools detect the encoding, but code that does not expect it reads it as an extra character (\ufeff) at the start of the first line.
What is the difference between CRLF and LF line endings?
Windows ends each line with two characters, carriage return and line feed (CRLF, \r\n). Linux and macOS use only a line feed (LF, \n). Code that splits on \n alone leaves a stray \r at the end of each line from a Windows file. Use sample8-crlf.txt to test for this.
Which TXT file should I use for performance testing?
Use sample9-large.txt. It has 15,000 numbered lines (about 942 KB), so you can check that your code reads it line by line and that the line count comes out as exactly 15,000.
If you want to know more about the TXT format you can find more information here.