How to convert Base64 to binary
- Paste the Base64 into Input · Base64. Line breaks, spaces, a
data:prefix, URL-safe-and_and missing padding are all accepted. - Each decoded byte appears as 8 bits in Output · Binary.
- Choose Separator under the output: Space (the default), None,
,,,or New line. - Copy output or Download the bits. Save bytes saves the decoded data as a file instead, with the extension taken from its content.
The Binary → Base64 toggle, or Binary to Base64, goes the other way.
How Base64 characters become bits
Every Base64 character stands for 6 bits: its position in the alphabet, from A = 0 to / = 63. Four characters give 24 bits, which the decoder regroups into three 8-bit bytes. Take SGkh:
| Character | S | G | k | h |
|---|---|---|---|---|
| Value | 18 | 6 | 36 | 33 |
| 6 bits | 010010 | 000110 | 100100 | 100001 |
Joined, those are 010010000110100100100001. Cut into bytes:
| Byte | 01001000 | 01101001 | 00100001 |
|---|---|---|---|
| Decimal | 72 | 105 | 33 |
| Text | H | i | ! |
So SGkh is Hi!, and the binary output reads 01001000 01101001 00100001. Character boundaries and byte boundaries only line up every 24 bits, which is why one wrong Base64 character can damage two neighbouring bytes. The step-by-step explanation walks through the encoder side of the same process.
Padding and the leftover bits
When the data is not a multiple of 3 bytes, the last group is short. Hi is 16 bits, which needs three Base64 characters (18 bits). The extra 2 bits are set to zero, and = fills the group to four characters:
| Base64 | Bits carried | Bytes out |
|---|---|---|
SGkh | 24 | 01001000 01101001 00100001 |
SGk= | 18, of which 2 are filler | 01001000 01101001 |
SA== | 12, of which 4 are filler | 01001000 |
The filler bits never show up in the output. More on why = exists is on the padding page.
Where a bit view helps
- Protocols and file headers often pack several yes/no flags into one byte. In binary you can read these bit fields directly instead of converting hex digits in your head.
- To compare two values, decode both and compare line by line with Separator set to New line; a single flipped bit is easy to spot.
- In teaching and puzzles, the 8-bit bytes next to the 6-bit groups show where the 33% size overhead comes from.
For anything longer than a few dozen bytes, hex is easier to read: Base64 to Hex shows the same bytes in a quarter of the space. Binary output is 8 characters per byte plus a separator, so a million Base64 characters (750,000 bytes) turn into about 6.75 million characters of binary. The output box shows the first 2 million; Copy output and Download always give the whole result.
Base64 to binary in code
import base64
" ".join(f"{b:08b}" for b in base64.b64decode("SGkh"))
# '01001000 01101001 00100001'
Array.from(Buffer.from("SGkh", "base64"), b => b.toString(2).padStart(8, "0")).join(" ");
// '01001000 01101001 00100001'
To write the decoded bytes to a binary file instead, open("out.bin", "wb").write(base64.b64decode(s)) in Python or fs.writeFileSync("out.bin", Buffer.from(s, "base64")) in Node. The Python and Node.js pages have the full file examples.
FAQ
Is Base64 to binary the same as decoding Base64?
The decoding is the same; only the display differs. This page writes the bytes as 0s and 1s. If you want the bytes as a file, which is what “binary” often means, use Base64 to File or the Save bytes button here.
Why 8 digits per byte when Base64 uses 6 bits per character?
The output shows bytes, and a byte is 8 bits. Base64 cuts the same bit stream into 6-bit pieces instead, so 3 bytes (24 bits) always map to 4 characters.
How do I get the bits without spaces?
Set Separator to None. SGk= then gives 0100100001101001 as one string.
What happens to the padding bits?
They are dropped. In SGk= the last character carries 6 bits but only 4 belong to the data; the other 2 are zeros that fill the character, and the decoder discards them.