Upload a file
  1. base64hub
  2. Other bases
  3. Binary to Base64

Binary to Base64 Converter: Bits to Base64

Paste bits, get Base64: 01001000 01101001 00100001 becomes SGkh. Separate bytes with spaces or commas, or paste one long bit string whose length is a multiple of 8.

Free no sign-up, no limits Local nothing uploaded Updated Oct 27, 2026
Input 0Bytes 0 BOutput 0

Processed in your browser. This page cannot send your data anywhere – how we know

How to convert binary to Base64

  1. Paste the bits into Input · Binary.
  2. The Base64 appears in Output · Base64 as you type.
  3. Under the output, Padding (=) adds or removes trailing = signs, and Line wrap breaks the result every 64 or 76 characters for PEM or MIME use.
  4. Copy output or Download. To check the result, flip the direction with Base64 → Binary or open Base64 to Binary.

How the input is read

The converter decides between two readings:

  • Grouped. If the bits are split by spaces, new lines, commas, semicolons or |, and no group is longer than 8 bits, each group is one byte. Short groups are allowed, so 7-bit ASCII such as 1001000 1101001 reads as Hi, and 1 0 1 is three bytes with the values 1, 0 and 1.
  • Continuous. If there are no separators, or any group is longer than 8 bits, all the bits are joined and cut into bytes from the left. The total must then be a multiple of 8.

0b prefixes are skipped in both cases. A character other than 0, 1 or a separator stops the conversion with its position.

Examples

BinaryBytesBase64
01001000 01101001 001000013SGkh
01001000 011010012SGk=
010010001SA==
01001000011010012SGk=
00000000 00000000 000000003AAAA
11111111 11111111 111111113////

Every 24 bits become exactly four characters, because Base64 reads the bit stream 6 bits at a time. All zeros map to A, the first character of the alphabet, and all ones to /, the last. The output is about a sixth as long as the binary input: 8 bits on the way in, 1.33 characters on the way out, per byte.

Where binary strings come from

Bit strings turn up in protocol specs and datasheets, in bitmask constants, in exercises on number systems, and in test vectors written out bit by bit. Base64 is the compact way to put the same bytes into JSON, a config file or an HTTP header. If you have the bits as hex already, Hex to Base64 is shorter to paste; if you have decimal byte values, use Decimal to Base64.

Binary to Base64 in code

import base64

bits = "0100100001101001"
data = int(bits, 2).to_bytes(len(bits) // 8, "big")
base64.b64encode(data).decode()       # 'SGk='

int(bits, 2) drops leading zeros, but to_bytes with the original length puts them back. For space-separated bytes, bytes(int(b, 2) for b in s.split()) is simpler.

const bits = "01001000 01101001";
Buffer.from(bits.split(" ").map(b => parseInt(b, 2))).toString("base64");   // 'SGk='

The Python and Node.js pages show the reverse direction and file handling.

Common problems

  • “15 bits is not a whole number of bytes”. The count in the message tells you how far off you are. Usually a leading zero was dropped from the first byte, as in 1001000 written for 01001000 inside an unbroken string.
  • Unexpected Base64 from grouped input. Check that no group has 9 or more digits. One long group switches the whole input to continuous mode and the byte boundaries move.
  • Letters or O instead of 0. Text copied from PDFs and chat apps sometimes contains a capital O or other look-alikes. The error message points at the position.

FAQ

How do I convert a binary string to Base64?

Paste the bits into the input. If they are grouped into bytes, each group becomes one byte; if they are one unbroken string, it is cut into 8-bit pieces. The Base64 appears as you type.

Why does the Base64 for my bits end in = signs?

The number of bytes is not a multiple of 3. Two bytes give one =, one byte gives ==. Untick Padding (=) if the receiver wants Base64 without it.

My bit string is not a multiple of 8. What now?

Base64 encodes whole bytes, so the tool stops with a message saying how many bits it found. Add the missing leading zeros to the first byte, or split the string into groups yourself so each group is read as its own byte.

Can I convert a binary file to Base64 here?

This page reads 0s and 1s typed as text. To encode an actual file, such as an image or a PDF, use File to Base64.