FormatterHQ

Binary to Base64

Convert binary digits — 8-bit bytes of 0s and 1s — into Base64 or Base64URL, with or without spaces between the bytes.

Loading tool…
Ready.

How to use the Binary to Base64

  1. Type or paste into the Binary box, or click Sample. You can also drop a text file on either box, or load one into the Base64 box with its Open file button.
  2. The Base64 box updates live as you type. It works both ways — edit the Base64 side to convert back, or click ⇄ Swap to exchange the sides.
  3. Adjust Alphabet in the options bar above the editors; the result refreshes immediately. Separator only affects the reverse direction, when you type in the Base64 box.
  4. Use Copy or Download on either box to take the result, or Clear to start again.

Binary to Base64, bit by bit

The binary to Base64 converter reads your 0s and 1s as bytes and encodes them as Base64. It is a great way to see how Base64 really works, because Base64 is itself defined in terms of bits: it regroups the input into 6-bit chunks and maps each chunk to one of 64 characters.

Example

Input:

01001000 01101001 00100001

Output:

SGkh

How the bits become characters

The three input bytes are joined into one 24-bit stream and cut into four 6-bit groups:

6-bit groupValueCharacter
01001018S
0001106G
10010036k
10000133h

Values 0–25 map to A–Z, 26–51 to a–z, 52–61 to 0–9, 62 to + and 63 to /. When the input is not a multiple of three bytes, the last group is padded with zero bits and = signs are added to the output.

The Base64 alphabet was chosen so that all 64 characters are printable and survive transport through email systems, terminals and older character sets. Six bits per character is the largest power of two for which that is possible.

Padding in action

With only two bytes, “Hi” gives 16 bits. Base64 needs a multiple of 6, so two zero bits are appended: 010010 000110 100100 becomes SGk, and one = marks the missing third byte, giving SGk=. A decoder drops the padding bits again, so no data is added.

Where + and / come from

Only two 6-bit groups produce the characters that cause trouble in URLs: 111110 (62) becomes + and 111111 (63) becomes /. You can see both with two bytes full of ones:

11111011 11111111
→ 111110 111111 1111(00)
→ +      /      8        Base64:    +/8=
                         Base64URL: -_8

Base64URL swaps those two characters for - and _ and usually drops the = padding, which is why JWTs and URL parameters use it. A single byte such as 01000001 (the letter A) shows the other padding case: 010000 01(0000) gives QQ==, with two padding signs because two bytes are missing from the final group.

Accepted input

  • Bytes separated by spaces, commas, semicolons or line breaks.
  • One continuous bit string whose length is a multiple of 8 — it is split into bytes automatically.
  • Groups shorter than 8 bits when separated (for example 1001000), which are read as the byte value.

Any group that is not binary, or whose value exceeds 255, is reported as an error so nothing is silently misread.

Uses

Besides teaching and exam practice, the tool helps when you design bit-level protocols, compose flag bytes or test decoders with precise inputs. If you have text rather than bits, convert it first with Text to Binary, or encode it directly with the Base64 Encoder.

Convert Base64 back into bits with Base64 to Binary. Everything runs in your browser.

Frequently asked questions

How does Base64 use binary?
Base64 splits the input bits into groups of six. Each 6-bit value from 0 to 63 is replaced by one character of the Base64 alphabet.
Do I need spaces between the bytes?
No. A continuous binary string works as long as its length is a multiple of 8 bits.
Why does my output end with =?
The input was not a multiple of three bytes, so padding was added to make the Base64 length a multiple of four.
Can I convert 7-bit groups?
Yes, if they are separated. Each group is read as a byte value, so 1001000 becomes 72 (the letter H).

Last updated October 3, 2026

Related tools