HTM
text/html
Magic Bytes
Offset: 0
3C 21 44 4F 43 54 59 50 45 20 48 54 4D 4C
HTM is a file extension for HyperText Markup Language documents, the standard format for web pages maintained by the World Wide Web Consortium (W3C) and WHATWG. It defines the structure and semantic meaning of web content, allowing browsers to interpret text, images, and interactive elements. Historically necessitated by operating systems requiring three-letter extensions, these plain text files are functionally identical to HTML but may contain executable scripts that require standard browser security sandboxing.
Validation Code
How to validate .htm files in Python
Python
def is_htm(file_path: str) -> bool:
"""Check if file is a valid HTM by magic bytes."""
signature = bytes([0x3C, 0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x48, 0x54, 0x4D, 0x4C])
with open(file_path, "rb") as f:
return f.read(14) == signature
How to validate .htm files in Node.js
Node.js
function isHTM(buffer: Buffer): boolean {
const signature = Buffer.from([0x3C, 0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x48, 0x54, 0x4D, 0x4C]);
return buffer.subarray(0, 14).equals(signature);
}
Go
func IsHTM(data []byte) bool {
signature := []byte{0x3C, 0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x48, 0x54, 0x4D, 0x4C}
if len(data) < 14 {
return false
}
return bytes.Equal(data[:14], signature)
}
API Endpoint
GET
/api/v1/htm
curl https://filesignature.org/api/v1/htm