Skip to content

TXT (.txt)

.txt file signature | text/plain

The TXT format is a plain text file format used across operating systems and text editors, with conventions standardized through the Internet media type text/plain and maintained by common software implementations. It is used for notes, source code, configuration files, logs, and other unformatted text exchanged between applications. TXT files are generally safe to open, although their contents may be misleading or renamed from other file types, so source verification remains important.

Safe

Magic Bytes

Offset 0
EF BB BF

Sources: Wikipedia

All Known Signatures

6 signature variants are documented for .txt files across multiple sources.

Hex Signature Offset Sources
EF BB BF 0 Wikipedia
FF FE 0 Wikipedia
FE FF 0 Wikipedia
FF FE 00 00 0 Wikipedia
00 00 FE FF 0 Wikipedia
0E FE FF 0 Wikipedia

Extension

.txt

MIME Type

text/plain

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .txt files in Python

Python
def is_txt(file_path: str) -> bool:
    """Check if file is a valid TXT by magic bytes."""
    signature = bytes([0xEF, 0xBB, 0xBF])
    with open(file_path, "rb") as f:
        return f.read(3) == signature

How to validate .txt files in Node.js

Node.js
function isTXT(buffer: Buffer): boolean {
  const signature = Buffer.from([0xEF, 0xBB, 0xBF]);
  return buffer.subarray(0, 3).equals(signature);
}

How to validate .txt files in Go

Go
func IsTXT(data []byte) bool {
    signature := []byte{0xEF, 0xBB, 0xBF}
    if len(data) < 3 {
        return false
    }
    return bytes.Equal(data[:3], signature)
}

API Endpoint

GET /api/v1/txt
curl https://filesignature.org/api/v1/txt

See the full API documentation for all endpoints and parameters.

Related Formats

Frequently Asked Questions

What is a .txt file?

A .txt file is identified by the magic bytes EF BB BF at byte offset 0. The TXT format is a plain text file format used across operating systems and text editors, with conventions standardized through the Internet media type text/plain and maintained by common software implementations. It is used for notes, source code, configuration files, logs, and other unformatted text exchanged between applications. TXT files are generally safe to open, although their contents may be misleading or renamed from other file types, so source verification remains important.

What are the magic bytes for .txt files?

The magic bytes for TXT files are EF BB BF at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .txt file?

To validate a .txt file, read the first bytes of the file and compare them against the known magic bytes (EF BB BF) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .txt files?

The primary MIME type for .txt files is text/plain.

Is it safe to open .txt files?

TXT (.txt) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.