What is the PBM file format?
The .pbm (Portable Bitmap) format is the 1-bit black-and-white member of the Netpbm family of uncompressed raster formats, alongside .pgm (grayscale) and .ppm (full RGB color). Created by Jef Poskanzer in the mid-1980s as part of the Pbmplus toolkit, it is designed for maximum simplicity and portability across operating systems.
A .pbm file begins with a two-byte magic number followed by an ASCII header declaring the image dimensions, then the pixel data. Two variants exist:
- P1 (ASCII): each pixel is the character
1(black) or0(white), separated by whitespace - fully human-readable and editable in any text editor. - P4 (binary): pixels are packed eight per byte, most-significant bit first, making the file roughly eight times smaller than its P1 equivalent.
The color depth is strictly 1-bit - pure black and white with no grayscale levels or anti-aliasing. There is no compression, no encryption, and no checksums. This simplicity makes .pbm a reliable interchange format in fax processing, OCR pipelines, laser-printer rasterization, and computer-vision binary-mask workflows.
Virtually every major image-processing tool supports it: GIMP, ImageMagick, IrfanView, and Photoshop can all read and write .pbm. A valid P1 .pbm file can even be created by hand in a plain text editor. For modern use cases requiring small file sizes, .png is typically preferred, but .pbm remains the standard choice when a strict binary mask is required.
Security & safety
RISK: LOWPBM is a passive, fully-documented raster image - header plus raw pixel bits, no scripts or executable content. Safe to open. Only practical concern: large uncompressed files (especially P1 ASCII) can be very large; convert to PNG to save space. No EXIF/metadata privacy risk.
Format details
in a nutshellPrograms that open PBM files
Technical details
deep spec| Color depth | 1-bit (strictly black and white; no grayscale) |
| P1 pixel encoding | ASCII: each pixel stored as character '1' (black) or '0' (white), whitespace-separated |
| P4 pixel encoding | Binary: 8 pixels packed per byte, most-significant bit first |
| Magic number | P1 (0x50 0x31) for ASCII variant; P4 (0x50 0x34) for binary variant |
| Header format | ASCII text - magic number followed by width and height (whitespace-separated integers) |
| Compression | None (raw uncompressed pixels) |
| Bit packing order | MSB-first for P4 binary variant |
| Sibling formats | .pgm (grayscale, P2/P5), .ppm (RGB color, P3/P6); together form the Netpbm/PNM format family |
| MIME type | image/x-portable-bitmap |
| Typical file size | A few KB to tens of MB (P4 binary is approximately 8x smaller than equivalent P1 ASCII) |
| Platform support | Windows, macOS, Linux, Unix |
| Common use cases | Fax processing, OCR, laser-printer rasterization, computer-vision binary masks |
| Human-readability | P1 (ASCII) variant is fully readable and editable in any text editor |
| Released | mid-1980s (Jef Poskanzer's Pbmplus toolkit) |
| Latest version | Stable since the 1990s; current Netpbm 10.x implements it (no format version bump) |
| Open standard | Yes · royalty-free |
| Specification | netpbm.sourceforge.net |
PBM conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about PBM files.