AnswerLion

TXT file example

TXT File Example: A Sample File and Its Structure

Get a working TXT file example with annotated structure, UTF-8 encoding rules, and robots.txt and llms.txt samples for AI discoverability.

Published · Updated · By AnswerLion

TXT File Example: A Sample File and Its Structure

A TXT file can open perfectly in your editor and still fail in another application. The extension doesn't tell software how to interpret its characters, and Unicode text requires an agreed encoding, as the ICU Unicode guide explains. Removing formatting doesn't remove the need for rules.

A reliable TXT file example therefore needs more than readable sentences. Treat it as a small contract between the person who creates it and the software that receives it: specify the encoding, line endings, and structure. Those choices make the difference between a file that merely looks right and one that another system can use correctly.

A Complete TXT File Example and What Each Part Does

Save the following fictional contact record as company-info.txt. Each numbered item represents a separate line in the file. Copy the content, not the list numbers, and press Enter after the Contact line to add the final line break.

  1. # Harbor Street Dental contact record
  2. # Encoding: UTF-8, LF
  3. Company: Harbor Street Dental
  4. Address: Harbor Street
  5. Phone: Not provided
  6. Hours: By appointment
  7. Services: cleaning | whitening | implants
  8. Contact: Zoé

The sample contains both human-readable instructions and machine-readable records. The opening comments describe the file, while the remaining lines provide named fields that a receiving application can extract.

Anatomy of the sample TXT file

Part Example content Purpose Risk if missing
Comment header # Harbor Street Dental contact record Names the file and its scope Readers cannot tell what the file is for
Encoding declaration # Encoding: UTF-8, LF Documents how bytes map to characters and lines Accents may display as garbled pairs if software guesses incorrectly
Key-value records Company: Harbor Street Dental Keeps one fact per line for line-based parsers Parsers cannot split fields reliably
List field cleaning | whitening | implants Carries several values with a known delimiter Software treats separate services as one undifferentiated value
Non-ASCII content Zoé Tests support for multilingual text Hidden encoding faults appear only when international content arrives
Final line break Newline after the last record Terminates the last line for line-based tools Scripts that expect terminated lines can drop the final record

Read the sample as a contract

A parser is software that reads content according to rules. For this sample, tell the parser to skip lines beginning with #, split each remaining line at its first colon, and trim surrounding spaces from field names and values.

Splitting at the first colon matters because values can contain punctuation, including times. For Services, apply an additional rule: split the value at each vertical bar and trim the spaces around each service.

Practical rule: A comment documents a setting. It doesn't change the file's bytes or configure the receiving application.

The encoding comment therefore doesn't save the file as UTF-8 by itself. Likewise, # means “comment” only because this particular file contract says so. TXT has no built-in comment syntax, field names, or list rules, and this sample contains no formatting codes or hidden page-layout data.

Where a TXT File Fits and When Another Format Wins

A conventional TXT file stores characters without embedded fonts, images, page layout, or complex document metadata. DOCX and PDF carry document presentation information; plain text leaves presentation to the application that opens it. Renaming a formatted document with a .txt extension doesn't convert its contents.

The format's foundations reach back to June 17, 1963, when the American Standards Association published ASCII, a seven-bit system with 128 code points numbered 0 through 127, according to ASCII World's history of ASCII. That shared character mapping helped different computers exchange readable text.

The illustration shows the distinction between plain characters and document formats that carry richer presentation.

An illustration showing a plain text file being converted into complex DOCX and PDF document formats.

Choose TXT for simple, explicit structures

The .txt extension names a plain-text container, not a schema or an encoding. The text/plain media-type guide distinguishes that content type from the additional rules a receiving system needs to interpret it.

These minimal uses work well when people need to edit the file directly and the content doesn't require nested records:

  • Notes: Write free prose, separating paragraphs with a blank line. TXT wins when the words matter more than typography.
  • Logs: Put an event on each line, with its timestamp first. A hypothetical entry is 2025-03-04 09:12:07 INFO backup completed; a fixed order helps people scan and software filter events.
  • Tab-delimited data: Start with a header such as Company[TAB]Contact, followed by matching columns. Replace [TAB] with an actual tab character, so commas within a value don't become separators.
  • Configuration: Use an agreed pattern such as timeout=30, with # comments only if the consuming application supports them. TXT wins for shallow settings that administrators inspect and change manually.

Choose another format when interpretation becomes complex

Requirement Better choice Reason
Spreadsheet imports CSV Spreadsheet tools provide established import controls
Nested records or API payloads JSON Its syntax explicitly represents objects, arrays, and values
Rendered headings and links Markdown Readable source text can produce structured presentation
Designed pages or print layout DOCX or PDF Formatting travels with the document

Plain text is flexible because its creator and receiver define delimiters, escaping, and validation. That responsibility includes security: never execute unknown text as a script or automatically render untrusted content merely because its filename ends in .txt.

If another system must parse the file, place a README beside it that defines the field rules, permitted values, and handling of unexpected content.

Encoding and Line Endings to Set Before You Save

Encoding and line-ending settings by use case

Use case Encoding Line ending Notes
Web delivery over HTTP UTF-8 LF Declare charset=UTF-8 in the Content-Type header
Windows-only tool or script UTF-8 CRLF Confirm the tool accepts UTF-8 before saving
Unix, macOS, or Linux pipeline UTF-8 LF Add a final newline for line-oriented tools
Cross-platform exchange UTF-8 LF Parsers should accept both LF and CRLF
Legacy Windows import Windows-1252 CRLF Use only when the receiving system explicitly requires it
Historical classic Mac system Encoding required by the receiving application CR Convert to LF and an agreed modern encoding before sharing

UTF-8 is the practical default because it supports international text while preserving ASCII compatibility. According to ASCII World's Unicode timeline, Unicode 1.0 arrived in 1991 with 7,161 characters across 24 scripts, retaining ASCII's first 128 code points, and Ken Thompson and Rob Pike designed UTF-8 in 1992.

Every valid ASCII file is therefore already valid UTF-8. That doesn't mean an ASCII file already contains international characters; it means you can retain its existing text unchanged while adding accented letters, Cyrillic, Greek, Arabic, Chinese characters, and emoji using UTF-8.

Separate characters from line boundaries

An encoding defines how bytes represent characters. A line-ending convention defines how software marks the end of a line, and UTF-8 doesn't select that convention for you. The UTF-8 specification, RFC 3629, defines the encoding rather than a universal application-level text-file structure.

Unix-like systems and modern macOS conventionally use LF, written \n. Windows conventionally uses CRLF, written \r\n, while historical systems can use CR, written \r.

Configure a cross-platform parser to accept LF and CRLF, normalize them internally, and avoid leaving carriage returns attached to field values. Otherwise, a value that appears to be cleaning can contain an invisible trailing character and fail an exact-match comparison.

A visible line on screen isn't proof of a correctly terminated record. Word wrapping changes the display, not the underlying line boundaries.

End the file with a newline so concatenation and line-oriented processing remain predictable. In the README, record encoding, newline convention, whether blank lines are allowed, and whether trailing whitespace matters. Those settings let another developer reproduce your intended interpretation without guessing.

How to Create, Save and Test a TXT File

Use an editor that exposes text settings rather than a word processor that prioritizes page design. This short workflow starts with the editor and the content.

An infographic showing the first two steps to create and save a basic text file.

  1. Open a plain-text editor. Use Notepad, TextEdit in Plain Text mode, VS Code, or nano. Confirm you're editing plain text rather than a rich-text document.

  2. Enter the sample content. Add test characters such as é, ü, ñ, and an emoji, plus international names where relevant. Check that every character displays correctly before saving.

  3. Save as UTF-8. Choose UTF-8 without a byte-order mark unless the receiver requires one, and confirm the filename is company-info.txt, not a doubled extension. Check the editor's encoding indicator after saving.

  4. Set the line endings. Select LF or the convention required by the receiving tool, then press Enter after the final record. Turn on visible whitespace or inspect the cursor position to confirm the ending.

  5. Reopen in another application. Open the saved file in a different editor and compare the accented characters and emoji. Matching content confirms that the second application decoded this test successfully.

  6. Inspect the encoding. On macOS, try file -I company-info.txt; on Linux, the equivalent is commonly file -i company-info.txt. With the international test content present, check for charset=utf-8, then use strict UTF-8 validation in the actual ingestion process rather than treating detection as proof.

  7. Verify web delivery. Inspect the response headers in browser developer tools and confirm Content-Type: text/plain; charset=UTF-8. RFC 6657 retains the historical US-ASCII default for text/plain, making explicit charset declaration important for international content.

For a visual demonstration of creating a text file, use this walkthrough alongside the checks.

Fixing Garbled Characters and Parsing Errors

TXT file symptoms, causes and fixes

Symptom Likely cause Fix
Accents appear as paired characters such as é UTF-8 bytes read as Windows-1252 Reopen using UTF-8, then save as UTF-8 without preserving the misdecoded characters
Question marks or replacement characters Legacy encoding, incorrect decoding, or lost characters Recover the original text, save as UTF-8, and check it with file -I on macOS or file -i on Linux
Stray characters at the top of the file Byte-order mark read as content Save as UTF-8 without BOM unless the receiver requires it
Works locally, fails through an API Missing or incorrect charset metadata Send Content-Type: text/plain; charset=UTF-8
Lines run together in a script CR-only or mixed line endings Normalize the file to LF or CRLF
Last record dropped by a tool Missing final newline Add a newline after the last record

A .txt extension doesn't guarantee consistent display in Notepad, a browser, and a database import. Each application still needs to select a decoder, and an incorrect guess can turn otherwise valid bytes into the wrong characters. Declare the encoding explicitly, both in the receiving application and in transport metadata.

Repair decoding before changing the text

When Zoé becomes Zoé, first reopen the original file using the correct encoding. Don't immediately replace characters by hand or save over the source, because saving a misdecoded view can make the corruption permanent.

Replacement characters require a different response. If a previous conversion already discarded the original character, changing the encoding label won't recreate it; recover an earlier copy or re-enter the correct content.

A useful diagnostic sequence separates the stages:

  • Inspect the source: Does the original file decode correctly as UTF-8?
  • Inspect transport: Does the response declare the same encoding?
  • Inspect parsing: Does the receiver use the agreed separators and line boundaries?

For parser-oriented exchange, UTF-8 without a byte-order mark is the default to choose unless the receiver explicitly needs a BOM. Record that decision so a future exporter doesn't introduce an unexpected prefix without anyone noticing.

robots.txt, llms.txt and sitemap.xml Compared

Web discovery text files compared

File Location Purpose Documented limit or format
robots.txt /robots.txt States which automated agents may crawl which paths Google ignores content beyond its documented size ceiling
llms.txt /llms.txt, or a subpath such as /docs/llms.txt Curated Markdown overview for language-model agents Markdown components follow a defined order
sitemap.xml /sitemap.xml, or another published location identified in robots.txt Lists URLs a site wants discovered and considered for indexing 50,000 URLs or 50 MB uncompressed per file, according to Google's sitemap guidance; split larger inventories and use an index

These files solve different problems. robots.txt communicates crawl rules, sitemap.xml supplies a URL inventory, and llms.txt provides editorial context. None replaces the others, and listing a URL in a sitemap doesn't itself secure indexing.

The llms.txt proposal describes a Markdown overview at /llms.txt, with subpath use also supported. Its components follow a specified sequence: a site-name heading, then a summary and additional context when included, followed by grouped resource links. The name heading is required; the other components are optional rather than universally mandatory.

Establish access before adding context

Robots files and XML sitemaps are established web mechanisms. llms.txt remains a proposal, so treat it as guidance for tools that use it, not an enforcement mechanism or a requirement for AI visibility. AnswerLion's explanation of what llms.txt is helps distinguish that supporting role from crawler access controls.

Use a deliberate publishing sequence:

  1. Review crawler access. Confirm robots.txt permits the automated agents the business wants to reach its public content.
  2. Publish the sitemap. Include the canonical, public URLs that belong in the site's discovery inventory.
  3. Add the curated overview. Select important answer pages for llms.txt and describe what each resource provides.

Keep access decisions separate from descriptions. An overview can describe a valuable page, but it doesn't override a rule that prevents a crawler from fetching it.

These are all text-based files, though sitemap.xml has XML syntax and llms.txt uses Markdown. Save them with UTF-8 and consistent LF or CRLF line endings, while validating each file against its own structure rather than applying the contact-record parser to every .txt file.

Annotated robots.txt and llms.txt Examples

Every line in these two files is part of a contract. A crawler or an AI tool reads the exact bytes you saved, so a directive only works if its syntax, spacing and line breaks match what the parser expects. The samples below use a fictional site. Copy the inline contents into separate file lines, without the list markers.

  • # Apply this group to crawlers without a more specific matching group
  • User-agent: *
  • # Exclude the administrative area
  • Disallow: /admin/
  • # Permit the public help subsection
  • Allow: /admin/help/
  • # Identify the sitemap location
  • Sitemap: https://example.com/sitemap.xml

User-agent: * selects the general group. Disallow excludes the administrative path from crawling, while the more specific Allow permits the help subsection within it. The Sitemap directive identifies the URL inventory; it isn't an access permission.

Robots rules aren't authentication. Protect private administrative content with access controls, not just crawler instructions. AnswerLion's guide to generating a robots.txt file provides a practical starting point for assembling the rules.

Add a crawler-specific group deliberately

To block GPTBot while retaining the general policy for other crawlers, add a separate group:

  • # A separate group for the named crawler
  • User-agent: GPTBot
  • Disallow: /

Use a blank line to make the group boundary readable. Specificity, not physical group order, determines which matching group Google selects; don't assume the first group wins or that the wildcard rules automatically merge into a named group. Keep each group's intended policy explicit.

This is the contract idea in practice. The parser doesn't infer what you meant from layout or intent. It matches the user-agent string against the groups exactly as written, then applies only the rules inside the winning group. A rule you assumed carried over doesn't exist for that crawler.

Write the overview as Markdown source

This illustrative llms.txt fragment uses Example Co and example links supplied for demonstration. Copy the literal Markdown characters inside each inline snippet.

  • # Example Co
  • > Example Co makes billing software for B2B SaaS companies. This overview points readers to service details and common questions.
  • ## Services
  • - Pricing: Plans, limits, and what each includes.
  • ## Contact
  • Contact information belongs on the business's verified public contact page.
  • ## Questions
  • - Security: Answers about certifications and data handling.

Keep the name heading first, the blockquote summary next, and resource sections afterward. Replace demonstration content with accurate business information before publishing.

Here the contract is Markdown structure rather than crawler directives. The # heading, the > blockquote and the - label link syntax are the terms a reading tool expects. Drop a bracket or a colon and the link still looks fine to a human eye but parses as plain text, so the resource effectively disappears from the overview.

Both files also share the plain-text foundation from earlier sections: UTF-8 encoding, consistent line endings, no rich formatting. Google's robots.txt documentation requires UTF-8 plain text and sets a 500 KiB maximum, ignoring content beyond that limit. Keep directives compact, then request /robots.txt and /llms.txt in a browser and confirm that both return the expected plain text rather than a styled error page.

Confirm Your TXT File Before You Publish It

A file is ready when its contents, saved bytes, and delivery settings agree. Use these pass conditions rather than relying on how it looks in a single editor.

An eight-step instructional checklist infographic for verifying and preparing a text file before publishing it online.

  • Structure passes: The contact-record file has a clear name such as company-info.txt, begins with its descriptive comment, and contains no rich-text formatting codes. Web files follow their own formats, rather than inheriting that comment-header requirement.
  • Encoding passes: The editor reports UTF-8, international test characters survive reopening, and the README records the BOM decision.
  • Newlines pass: The entire file uses the agreed LF or CRLF convention and includes a final newline.
  • Delivery passes: The server returns text/plain with charset=UTF-8 for the TXT resources, root-level discovery files load correctly, and robots.txt stays within Google's documented ceiling. Serve the sitemap as XML rather than forcing it into the TXT media type.

For website discovery, confirm the intended AI crawlers can access public content, publish the sitemap, and then add llms.txt. Use the sitemap verification checklist and request each published file to confirm its actual response.

A reliable text file is a documented agreement, not just an extension. Start with the checklist today and keep the receiving system's requirements beside the file.


As a professional AEO agency, AnswerLion reviews crawler access, sitemaps, and llms.txt alongside how major AI engines describe your business, then prioritizes the fixes. After the call, we confirm the questions to test, run them through the major AI engines, and send a short written report with gaps and recommended first fixes. Visit AnswerLion to connect your technical publishing checks with a measured AI visibility review.

Related guides

Want this done for your business?

Request an AEO audit and we will run your customers' questions through every major AI engine.

Book a call
Book a discovery call
Open in a new tab