Skip to content

XPM (.xpm)

.xpm file signature | image/x-xpixmap

X PixMap (XPM) is an ASCII-based image file format originally developed for the X Window System and now maintained within the X.Org ecosystem. It is used to store small bitmap images, especially application icons, cursors, and other graphical assets in Unix-like desktop environments. Because it is plain text and widely supported by image toolkits, XPM is generally low risk, though it is now largely a legacy format.

Safe

Magic Bytes

Offset 0
2F 2A 20 58 50 4D 20 2A

Sources: Wikipedia

Extension

.xpm

MIME Type

image/x-xpixmap

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .xpm files in Python

Python
def is_xpm(file_path: str) -> bool:
    """Check if file is a valid XPM by magic bytes."""
    signature = bytes([0x2F, 0x2A, 0x20, 0x58, 0x50, 0x4D, 0x20, 0x2A])
    with open(file_path, "rb") as f:
        return f.read(8) == signature

How to validate .xpm files in Node.js

Node.js
function isXPM(buffer: Buffer): boolean {
  const signature = Buffer.from([0x2F, 0x2A, 0x20, 0x58, 0x50, 0x4D, 0x20, 0x2A]);
  return buffer.subarray(0, 8).equals(signature);
}

How to validate .xpm files in Go

Go
func IsXPM(data []byte) bool {
    signature := []byte{0x2F, 0x2A, 0x20, 0x58, 0x50, 0x4D, 0x20, 0x2A}
    if len(data) < 8 {
        return false
    }
    return bytes.Equal(data[:8], signature)
}

API Endpoint

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

See the full API documentation for all endpoints and parameters.

Related Formats

Frequently Asked Questions

What is a .xpm file?

A .xpm file is identified by the magic bytes 2F 2A 20 58 50 4D 20 2A at byte offset 0. X PixMap (XPM) is an ASCII-based image file format originally developed for the X Window System and now maintained within the X.Org ecosystem. It is used to store small bitmap images, especially application icons, cursors, and other graphical assets in Unix-like desktop environments. Because it is plain text and widely supported by image toolkits, XPM is generally low risk, though it is now largely a legacy format.

What are the magic bytes for .xpm files?

The magic bytes for XPM files are 2F 2A 20 58 50 4D 20 2A at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .xpm file?

To validate a .xpm file, read the first bytes of the file and compare them against the known magic bytes (2F 2A 20 58 50 4D 20 2A) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .xpm files?

The primary MIME type for .xpm files is image/x-xpixmap.

Is it safe to open .xpm files?

XPM (.xpm) 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.