XPM file format: what it is and how to use it
XPM is X11's icon format: images written as valid C source code, the 1989 answer to shipping pictures inside programs. Learn when to use it and what to choose instead.
-
No uploadsFiles stay on your device
-
Batch processingHandle multiple files at once
-
100% privateNo sign-up, no tracking
What is a XPM file?
An .xpm file is an image written as C source code, the X PixMap format from 1989: a static char * array where each character maps to a color and each string is a pixel row, so the image compiles straight into a program. It was how X11 applications shipped icons and cursors before resources and binaries made better answers.
When should you use XPM?
- X11 and Motif programs: the icon format the classic Unix desktop expects.
- C-embedded images: graphics that live inside source, not beside it.
- Hand-editable icons: pixels as characters you can literally type.
When is another format a better fit?
For everything else, meaning PNG, ICO or SVG, XPM's C-source trick is a relic: enormous for its content, limited to tiny indexed images, useless outside code. Convert it to PNG and the picture finally lives as a picture.
The short version: XPM is the image-that-is-source-code: a cute 1989 hack. Convert it to PNG for the real world.
How to open a XPM file
On Windows
Double-click the file, or open it with GIMP.
On macOS
XnView opens XPM files on macOS.
In your browser
Open XPM files right in a browser tab or with the dexrr viewer. No install, no upload.
Also opens in
-
GIMP
-
ImageMagick -
XnView -
X11 apps
View or convert XPM files
A quick preview or a new format. No install, no upload.
XPM technical details
- Full name
- X PixMap
- Extensions
- .xpm
- MIME type
-
image/x-xpixmap, image/xpm - Magic bytes
-
2F 2A 20 58 50 4D 20 2A 2F (/* XPM */) - Compression
- None (uncompressed)
- Developer
- Arnaud Le Hors / X Consortium
XPM questions, answered
How do I open a .xpm file?
ImageMagick, GIMP, FFmpeg and X11 tools read it; general viewers rarely do. dexrr displays and converts xpm files directly in your browser.
Can I convert XPM files online?
Yes, dexrr converts xpm locally in your browser: XPM to PNG to make it a real image file.
Is XPM better than PNG?
Only if you want an image embeddable in C source, its entire reason to exist. For images as images, PNG wins on every metric.
Why does my .xpm file look like code?
Because it is. XPM stores the image as a C string array where each character is a pixel color. That was the 1989 trick.
Is the XPM format outdated?
Yes, a Unix-workstation relic that survives in old X11 programs and embedded-resource hacks.