Skip to content

XHT (.xht)

.xht file signature | application/xhtml+xml

Safe

Magic Bytes

Offset 0
3C 68 74 6D 6C 20 78 6D 6C 6E 73 3D

Sources: Apache Tika

Extension

.xht

MIME Type

application/xhtml+xml

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .xht files in Python

Python
def is_xht(file_path: str) -> bool:
    """Check if file is a valid XHT by magic bytes."""
    signature = bytes([0x3C, 0x68, 0x74, 0x6D, 0x6C, 0x20, 0x78, 0x6D, 0x6C, 0x6E, 0x73, 0x3D])
    with open(file_path, "rb") as f:
        return f.read(12) == signature

How to validate .xht files in Node.js

Node.js
function isXHT(buffer: Buffer): boolean {
  const signature = Buffer.from([0x3C, 0x68, 0x74, 0x6D, 0x6C, 0x20, 0x78, 0x6D, 0x6C, 0x6E, 0x73, 0x3D]);
  return buffer.subarray(0, 12).equals(signature);
}

How to validate .xht files in Go

Go
func IsXHT(data []byte) bool {
    signature := []byte{0x3C, 0x68, 0x74, 0x6D, 0x6C, 0x20, 0x78, 0x6D, 0x6C, 0x6E, 0x73, 0x3D}
    if len(data) < 12 {
        return false
    }
    return bytes.Equal(data[:12], signature)
}

API Endpoint

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

See the full API documentation for all endpoints and parameters.

Frequently Asked Questions

What is a .xht file?

A .xht file is a XHT file.

What are the magic bytes for .xht files?

The magic bytes for XHT files are 3C 68 74 6D 6C 20 78 6D 6C 6E 73 3D at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .xht file?

To validate a .xht file, read the first bytes of the file and compare them against the known magic bytes (3C 68 74 6D 6C 20 78 6D 6C 6E 73 3D) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .xht files?

The primary MIME type for .xht files is application/xhtml+xml.

Is it safe to open .xht files?

XHT (.xht) 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.