User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times

Drop BMP file here or click to browse

Supports .bmp files up to 50 MB

Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

About

BMP (Bitmap) files store pixel data uncompressed, producing large file sizes that complicate embedding in HTML, CSS, or JSON payloads. Converting a BMP to Base64 encodes the binary data as an ASCII string using a 6-bit alphabet (64 characters: A - Z, a - z, 0 - 9, +, /). The output is approximately 33% larger than the source because every 3 input bytes map to 4 output characters. This tool performs the conversion entirely in your browser using the native FileReader API. No data leaves your machine.

Incorrect Base64 encoding breaks inline images, corrupts API payloads, and triggers CORS failures in production. A common mistake is omitting the Data URI prefix (data:image/bmp;base64,) when embedding in <img> tags, or including it when the backend expects raw Base64. This converter handles both cases explicitly. Note: BMP files lack compression. For web embedding, consider converting to PNG or WebP first if bandwidth matters. This tool approximates final string size before conversion so you can verify payload limits.

bmp to base64 image converter base64 encoder bitmap converter data uri bmp encoder image to text

Formulas

The Base64 encoding maps every group of 3 input bytes to 4 output ASCII characters. The output length is computed as:

Lout = 4 โ‹… ceil(Lin3)

Where Lin = file size in bytes, Lout = Base64 string length in characters. The size overhead ratio is:

R = LoutLin 1.333

This means a 1MB BMP file produces approximately 1.33MB of Base64 text. When the Data URI prefix data:image/bmp;base64, (22 characters) is included, the total becomes Lout + 22. BMP file validity is confirmed by checking the first 2 bytes equal 0x42 0x4D (ASCII "BM"). The pixel data offset is read from bytes 10 - 13 as a 32-bit little-endian integer.

Reference Data

PropertyBMP Format DetailBase64 Impact
Magic Bytes0x42 0x4D ("BM")Validated before conversion
Bit Depth: 1-bitMonochrome, palette-indexedSmallest output per pixel
Bit Depth: 4-bit16 colors, palette-indexed~33% larger than source
Bit Depth: 8-bit256 colors, palette-indexed~33% larger than source
Bit Depth: 16-bitHigh color, 65,536 colorsModerate Base64 size
Bit Depth: 24-bitTrue color, 16.7M colorsLarge Base64 output
Bit Depth: 32-bitTrue color + alpha channelLargest Base64 output
Compression: BI_RGBNo compression (most common)Direct byte-to-Base64 mapping
Compression: BI_RLE8Run-length encoding, 8-bitSmaller source, smaller output
Compression: BI_RLE4Run-length encoding, 4-bitSmaller source, smaller output
Max File Size (practical)~50MB in-browser~66.7MB Base64 string
MIME Typeimage/bmp or image/x-bmpUsed in Data URI prefix
Data URI PrefixN/Adata:image/bmp;base64,
Base64 AlphabetN/AA-Z a-z 0-9 + / = padding
Encoding Ratio3 bytes input4 characters output
PaddingBMP rows padded to 4-byte boundary= or == appended if needed
Header Size (BITMAPINFOHEADER)54 bytes minimum72 Base64 characters
EndiannessLittle-endianPreserved in Base64 encoding
Color Space (v5)sRGB / calibrated RGBMetadata preserved in binary
Browser SupportUniversal (all browsers)FileReader API: IE10+

Frequently Asked Questions

Base64 encoding uses 6 bits per character to represent data, while the source binary uses 8 bits per byte. Every 3 input bytes (24 bits) are split into 4 groups of 6 bits, producing 4 output characters. The ratio is 4รท3 โ‰ˆ 1.333, yielding a 33.3% size increase. If your BMP is 3MB, expect approximately 4MB of Base64 text.
Include the prefix (data:image/bmp;base64,) when embedding directly in HTML <img src> attributes, CSS background-image: url() declarations, or Markdown image syntax. Use raw Base64 (without the prefix) when sending binary payloads to REST APIs, storing in database BLOB fields, or when the receiving system adds its own MIME header. Mixing these up is the most common cause of broken inline images.
No. The conversion reads the raw bytes of the BMP file and encodes them directly to Base64. No pixel manipulation, color space conversion, or resampling occurs. The decoded Base64 output will produce a byte-identical copy of the original file. This is a lossless encoding of the binary, not an image transformation.
The practical limit is approximately 50MB, constrained by browser memory allocation for the FileReader API and the resulting Base64 string (which will be ~66.7MB). Files beyond this may cause tab crashes on devices with limited RAM. For BMP files exceeding 50MB, use a server-side tool or command-line utility like OpenSSL (openssl base64 -in file.bmp).
The tool reads the first 2 bytes of the file as an ArrayBuffer and checks for the BMP magic number: 0x42 0x4D (ASCII characters "B" and "M"). This is the same check used by image libraries and operating systems. If the magic bytes do not match, the conversion is rejected with an error message, preventing corrupt or misnamed files from producing invalid Base64 output.
Yes, but with caveats. In CSS custom properties, the string must be wrapped correctly: --bg: url(data:image/bmp;base64,...). In JavaScript template literals, Base64 is safe because the alphabet (A-Z a-z 0-9 + / =) contains no backtick or ${ sequences. However, very large strings (over 1MB) may cause JavaScript parser slowdowns in some bundlers. Consider loading from a separate file if performance is critical.
Some systems (MIME email, PEM certificates, certain legacy APIs) require Base64 to be wrapped at 76 characters per line per RFC 2045. Other systems (JSON, Data URIs, modern web APIs) require a single continuous string with no line breaks. Inserting line breaks where they are not expected corrupts the data. This tool defaults to no wrapping for web use but offers configurable wrapping at 76 or 64 character widths for email/PEM compatibility.