Skip to content

TXT (.txt)

.txt file signature | text/plain

UTF-16LEbyte order mark, commonly seen in text files.[28][29][30]

Safe

Magic Bytes

Offset 0
FE FF

Sources: Apache Tika, Wikipedia

All Known Signatures

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

Hex Signature Offset Sources
FE FF 0 Apache Tika, Wikipedia
FF FE 0 Apache Tika, Wikipedia
EF BB BF 0 Apache Tika, Wikipedia
54 68 69 73 20 69 73 20 54 65 58 2C 0 Apache Tika
54 68 69 73 20 69 73 20 4D 45 54 41 46 4F 4E 54 2C 0 Apache Tika
2F 2A 0 Apache Tika
2F 2F 0 Apache Tika
3B 3B 0 Apache Tika
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([0xFE, 0xFF])
    with open(file_path, "rb") as f:
        return f.read(2) == signature

How to validate .txt files in Node.js

Node.js
function isTXT(buffer: Buffer): boolean {
  const signature = Buffer.from([0xFE, 0xFF]);
  return buffer.subarray(0, 2).equals(signature);
}

How to validate .txt files in Go

Go
func IsTXT(data []byte) bool {
    signature := []byte{0xFE, 0xFF}
    if len(data) < 2 {
        return false
    }
    return bytes.Equal(data[:2], signature)
}

API Endpoint

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

See the full API documentation for all endpoints and parameters.

Frequently Asked Questions

What is a .txt file?

A .txt file is a TXT file. UTF-16LEbyte order mark, commonly seen in text files.[28][29][30]

What are the magic bytes for .txt files?

The magic bytes for TXT files are FE FF 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 (FE FF) 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.