᠎᠎᠎          
51K

Bitmap to Byte Array Converter

World's simplest bitmap tool
This is a free and fast online utility that converts the color channels of every BMP pixel into a byte array. You can use the configuration options (below) to print the channels as decimal RGB bytes or two-digit hexadecimal bytes and arrange them in any RGB channel order. Extra options allow you to add a 0x prefix, change the hex letter case, choose the array dimensions and brackets, customize byte and pixel separators, and preserve the bitmap's row width. Created by graphics designers from team Browserling.
Check out our main project! Browserling
We created Browserling – get a cloud browser in 5 seconds. Check it out!
Byte Format and Order
Write each pixel channel as a decimal byte from 0 to 255.
Write each pixel channel as a two-digit hex value from 00 to ff.
Choose the order of the red, green, and blue bytes in every output pixel.
Hex Format
These options apply only when "Print Hex Bytes" is selected.
Place "0x" before every hexadecimal channel byte.
Use uppercase A through F in hexadecimal channel values.
Array Format
Choose how pixels and bitmap rows are grouped into arrays.
Select the bracket pair used.
Set the delimiter between the three bytes inside each pixel.
Set the delimiter between one complete pixel and the next.
Line Wrapping
Insert a line break after each complete bitmap row.

What is a Bitmap to Byte Array Converter?

learn more about this tool
This free online browser-based program converts a BMP image into a byte array representing its pixel colors. A byte array is an ordered sequence of 8-bit values. Each byte can be written as a decimal number from 0 to 255 or as a hexadecimal value from 00 to ff. In this conversion, every pixel contributes three such bytes: one for red, one for green, and one for blue. The tool reads the bitmap row by row, starting at the upper-left pixel and continuing to the lower-right pixel, and writes the three-channel values of each pixel in sequence. The "Print RGB Bytes" mode writes channel values as decimal numbers. For example, a white pixel becomes "255, 255, 255", a black pixel becomes "0, 0, 0", and a bright red pixel becomes "255, 0, 0". The "Print Hex Bytes" mode writes the same channel values in base 16. Each byte uses exactly two hex digits, from 00 to ff, so the same white, black, and red pixels become "ff, ff, ff", "00, 00, 00", and "ff, 00, 00". Although colors are commonly described in RGB order, standard 24-bit BMP files usually store the three-channel bytes in BGR order. You can select BGR in the byte-order options to reproduce this channel order, use RGB for a more conventional color representation, or choose one of the other supported orders: RBG, GRB, GBR, or BRG. Hexadecimal output can also be customized by adding the "0x" prefix and using uppercase letters A through F. You can output the bytes as a plain list such as "r, g, b, r, g, b", a one-dimensional array such as "[r, g, b, r, g, b]", a pixel-grouped array such as "[[r, g, b], [r, g, b]]", a row-grouped array such as "[[r, g, b, r, g, b], ...]", or a fully nested array such as "[[[r, g, b], [r, g, b]], ...]". The bracket type and the separators between channel values and complete pixels can be adjusted independently. You can also insert a line break between consecutive bitmap rows so that the text layout follows the width and row structure of the original bitmap. To perform the reverse conversion and build a BMP image from pixel byte values, use our Convert Byte Array to Bitmap tool. Bmp-abulous!

Bitmap to Byte Array Converter examples

Click to use
Sonic Sprite as an RGB Byte Array
In this example, we convert a 124×164 pixel-art BMP of Sonic the Hedgehog into decimal pixel bytes. We keep the channels in RGB order and place all their values into a single, one-dimensional array enclosed in square brackets. Both the channel and pixel separators are a comma followed by a space. (Source: Sega.)
In this example, we convert a 124×164 pixel-art BMP of Sonic the Hedgehog into decimal pixel bytes. We keep the channels in RGB order and place all their values into a single, one-dimensional array enclosed in square brackets. Both the channel and pixel separators are a comma followed by a space. (Source: Sega.)
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, ...
Required options
These options will be used automatically if you select this example.
Write each pixel channel as a decimal byte from 0 to 255.
Write each pixel channel as a two-digit hex value from 00 to ff.
Choose the order of the red, green, and blue bytes in every output pixel.
Place "0x" before every hexadecimal channel byte.
Use uppercase A through F in hexadecimal channel values.
Choose how pixels and bitmap rows are grouped into arrays.
Select the bracket pair used.
Set the delimiter between the three bytes inside each pixel.
Set the delimiter between one complete pixel and the next.
Insert a line break after each complete bitmap row.
Orange Kitten in BGR Hex Bytes
In this example, we convert a BMP photo of an orange kitten to lowercase hex bytes in BGR order. Standard 24-bit BMP files commonly store blue before green and red, so this order follows the usual BMP channel layout. Each pixel is grouped in square brackets, with commas between channels and semicolons between pixels. (Source: Pexels.)
In this example, we convert a BMP photo of an orange kitten to lowercase hex bytes in BGR order. Standard 24-bit BMP files commonly store blue before green and red, so this order follows the usual BMP channel layout. Each pixel is grouped in square brackets, with commas between channels and semicolons between pixels. (Source: Pexels.)
[[[18, 13, 14]; [15, 10, 11]; [15, 10, 11]; [19, 14, 15]; [19, 14, 15]; [18, 13, 14]; [17, 12, 13]; [16, 11, 12]; [14, 12, 11]; [13, 11, 10]; [11, 0f, 0e]; [10, 0e, 0d]; [0e, 0c, 0b]; [0d, 0b, 0a]; [0b, 09, 08]; [0b, 09, 08]; [0c, 0a, 0a]; [0c, 0a, 0a]; [0c, 0a, 0a]; [0c, 0a, 0a]; [0b, 09, 09]; [0a, 08, 08]; [0a, 08, 08]; [09, 07, 07]; [09, 07, 07]; [09, 07, 07]; [09, 07, 07]; [09, 07, 07]; [09, 07, 07]; [0a, 08, 08]; [0a, 08, 08]; [0b, 09, 09]; [0b, 09, 09]; [0b, 09, 09]; [0c, 0a, 0a]; [0c, 0a, 0a]; [0c, 0a, 0a]; [0d, 0b, 0b]; [0d, 0b, 0b]; [0e, 0c, 0c]; [0c, 0a, 0a]; [0c, 0a, 0a]; [0c, 0a, 0a]; [0c, 0a, 0a]; [0d, 0b, 0b]; [0d, 0b, 0b]; [0d, 0b, 0b]; [0d, 0b, 0b]; [0d, 0b, 0b]; ...
Required options
These options will be used automatically if you select this example.
Write each pixel channel as a decimal byte from 0 to 255.
Write each pixel channel as a two-digit hex value from 00 to ff.
Choose the order of the red, green, and blue bytes in every output pixel.
Place "0x" before every hexadecimal channel byte.
Use uppercase A through F in hexadecimal channel values.
Choose how pixels and bitmap rows are grouped into arrays.
Select the bracket pair used.
Set the delimiter between the three bytes inside each pixel.
Set the delimiter between one complete pixel and the next.
Insert a line break after each complete bitmap row.
BGR Hex Rows of a Tropical Lagoon
In this example, we convert an aerial BMP photo of a lagoon into uppercase hex bytes in BGR order – blue, green, and red. Each byte has a 0x prefix, which is commonly used in programming to identify hexadecimal values. We separate the three bytes of each pixel with dashes, separate neighboring pixels with spaces, and place each bitmap row in round brackets on a separate line. (Source: Pexels.)
In this example, we convert an aerial BMP photo of a lagoon into uppercase hex bytes in BGR order – blue, green, and red. Each byte has a 0x prefix, which is commonly used in programming to identify hexadecimal values. We separate the three bytes of each pixel with dashes, separate neighboring pixels with spaces, and place each bitmap row in round brackets on a separate line. (Source: Pexels.)
((0x25-0x1C-0x15 0x2E-0x2A-0x22 0x21-0x27-0x1C 0x22-0x2E-0x1F 0x3A-0x4B-0x39 0x40-0x51-0x3C 0x24-0x31-0x1B 0x2E-0x39-0x23 0x27-0x34-0x22 0x1A-0x25-0x13 0x25-0x2B-0x1A 0x2A-0x2B-0x1B 0x2B-0x2B-0x1B 0x27-0x28-0x18 0x31-0x34-0x24 0x1F-0x25-0x14 0x2B-0x2B-0x1F 0x2D-0x2F-0x20 0x1C-0x22-0x11 0x15-0x1E-0x0A 0x19-0x22-0x0E 0x12-0x1A-0x09 0x22-0x27-0x18 0x2D-0x31-0x25 0x17-0x21-0x11 0x33-0x3C-0x2C 0x1E-0x21-0x15 0x26-0x26-0x1A 0x20-0x1C-0x11 0x26-0x1D-0x14 0x26-0x1B-0x13 0x57-0x4B-0x46 0x64-0x60-0x64 0x59-0x54-0x56 0x58-0x52-0x53 0x38-0x31-0x2F 0x33-0x2B-0x25 0x36-0x2D-0x24 0x2F-0x25-0x1B 0x26-0x1E-0x11 0x2C-0x28-0x1A 0x33-0x2D-0x20 ...
Required options
These options will be used automatically if you select this example.
Write each pixel channel as a decimal byte from 0 to 255.
Write each pixel channel as a two-digit hex value from 00 to ff.
Choose the order of the red, green, and blue bytes in every output pixel.
Place "0x" before every hexadecimal channel byte.
Use uppercase A through F in hexadecimal channel values.
Choose how pixels and bitmap rows are grouped into arrays.
Select the bracket pair used.
Set the delimiter between the three bytes inside each pixel.
Set the delimiter between one complete pixel and the next.
Insert a line break after each complete bitmap row.
All bitmap tools
Didn't find the tool you were looking for? Let us know what tool we are missing and we'll build it!
Quickly convert an opaque bitmap to a transparent bitmap.
Quickly substitute one color for another in a bitmap.
Quickly find all colors in a bitmap and extract them.
Quickly turn a color bitmap into a grayscale bitmap.
Quickly blur an area of a bitmap.
Quickly sharpen an area of a bitmap.
Quickly pixelate an area of a bitmap.
Quickly create a bitmap file from random, colorful pixels.
Quickly change the width/height of a bitmap.
Quickly select a region from a bitmap.
Quickly rotate a bitmap by any angle.
Quickly add a border around or inside a bitmap.
Quickly delete a border that surrounds a bitmap.
Quickly animate a bitmap sprite sheet.
Quickly create a byte array from a BMP image.
Quickly convert a BMP file to the base-64 encoding.
Quickly convert base-64 encoding to a BMP file.
Coming soon These bitmap tools are on the way
Edit and Draw Bitmaps
Create and edit bitmaps in your browser.
Compress a Bitmap
Make a bitmap smaller in size.
Uncompress a Bitmap
Convert a compressed bitmap to a raw RGB pixel bitmap.
Convert RGB Bitmap to BGR Bitmap
Convert BMP colors in RGB order to BGR order
Convert BGR Bitmap to RGB Bitmap
Convert BMP colors in BGR order to RGB order
Change Bitmap Depth
Change the number of bits per pixel of a bitmap.
Swirl a Bitmap
Create a swirl of any radius in a bitmap.
Make Bitmap Black and White
Reduce all bitmap colors to just black and white.
Merge Bitmaps
Join two or more bitmaps together.
Overlay Bitmaps
Place two or more bitmaps on top of each other.
Split a Bitmap
Split a bitmap into multiple independent bitmaps.
Extract a Bitmap Fragment
Extract one or more selected areas from a bitmap.
Duplicate a Bitmap
Make copies of bitmaps and paste them together.
Skew a Bitmap
Skew a bitmap by an arbitrary angle.
Shift a Bitmap
Shift a bitmap to the left or right.
Flip a Bitmap Vertically
Turn a bitmap upside-down.
Flip a Bitmap Horizontally
Make a mirror copy of a bitmap.
Convert Byte Array to Bitmap
Create a BMP from a byte array.
Convert Bitmap to Webp
Convert a BMP to a Webp.
Convert Webp to Bitmap
Convert a Webp to a BMP.
Convert Bitmap to PNG
Convert a BMP to a PNG.
Convert PNG to Bitmap
Convert a PNG to a BMP
Convert Bitmap to JPEG
Convert a BMP to a JPG.
Convert JPEG to Bitmap
Convert a JPG to a BMP.
Convert Bitmap to BPG
Convert a BMP to a BPG.
Convert BPG to Bitmap
Convert a BPG to a BMP.
Convert GIF to Bitmap
Save GIF frames as BMP images.
Convert BMP to GIF
Convert a bitmap to a single-frame GIF.
Convert Bitmap to Data URI
Create a Data URL scheme of a bitmap.
Convert Data URI to Bitmap
Convert a Data URL scheme back to a bitmap image.
BitBlt Bitmaps
Bit Blit two or more BMPs.
Replace Bitmap Color Index
Put a new color table in a BMP.
Print Bitmap Color Index
Extract the color table of a BMP.
Print Raw Bitmap Pixels
Extract raw RGB pixels from a BMP and print them out as text.
Convert Raw RGB to BMP
Create a bitmap image from raw RGB pixels.
Randomize Bitmap Color Index
Randomly rearrange colors in the BMP color table.
Optimize a Bitmap
Reduce a BMP's memory footprint.
Destroy a BMP
Destroy parts of a bitmap and make it glitchy.