Utilities
Detect file type from magic bytes API
Sniff a file type from its leading bytes (supplied as hex or base64) by matching against a table of well-known magic-number signatures (PNG, JPEG, GIF, PDF, ZIP/Office, gzip, WebP, MP3/ID3, MP4 ftyp, ELF, Windows PE, and more), returning the detected MIME type, canonical extension, category, and the matched signature with its byte offset. Content-based, not extension-based, so it catches mislabeled/spoofed files. Answers 'what file type are these bytes','is this really a PNG','detect MIME from a base64 prefix'.
Price$0.01per request
MethodPOST
Route/v1/util/util-mime-magic
StatusLive
MIME typeapplication/json
Rate limit120/minute
CacheNo cache
utilmimemagic-numberfile-typesignaturesniffbinarydetect
API URL
Integration docshttps://x402.hexl.dev/v1/util/util-mime-magicExample request
{
"hex": "89504E470D0A1A0A"
}Example response
{
"detected": true,
"mime": "image/png",
"extension": "png",
"category": "image",
"signature": "PNG",
"matchedHex": "89504E470D0A1A0A",
"offset": 0,
"bytesInspected": 8,
"prefixHex": "89 50 4E 47 0D 0A 1A 0A"
}Input schema
{
"type": "object",
"required": [],
"properties": {
"bytes": {
"type": "string",
"examples": [
"89504E470D0A1A0A"
]
},
"hex": {
"type": "string",
"examples": [
"89504E470D0A1A0A"
]
},
"base64": {
"type": "string",
"examples": [
"JVBERi0xLjQ="
]
},
"encoding": {
"type": "string",
"enum": [
"hex",
"base64"
],
"examples": [
"hex"
]
}
},
"examples": [
{
"hex": "89504E470D0A1A0A"
},
{
"base64": "JVBERi0xLjQ="
}
]
}Output schema
{
"type": "object",
"additionalProperties": true
}