Block 1
SGVsInput bytes
01001000
01100101
01101100
6-bit indexes
010010
000110
010101
101100
Interactive Base64 explainer
Base64 is a binary-to-text encoding. It takes bytes, groups their bits, and rewrites them as safe ASCII characters for email, JSON, HTML, URLs, APIs, certificates, and tokens.
Core rule
3
bytes
24 bits
4
characters
4 x 6 bits
Because 24 bits divide cleanly into four 6-bit numbers, each number can choose one character from a 64-character alphabet.
Live encoding lab
The demo first converts text to UTF-8 bytes, then encodes those bytes. For long input, the bit walkthrough shows the first 18 bytes so the layout stays readable.
Samples
UTF-8 bytes
5
Output chars
8
Padding
1
Expansion
60%
Base64 output
4 x ceil(5 / 3) = 8 characters
SGVsbG8=
Base64URL version
Base64URL swaps + for -, swaps / for _, and usually removes trailing padding.
SGVsbG8
The mechanics
Each block below takes up to three input bytes. Missing bytes at the end become zero bits for calculation, and the corresponding output slots become padding characters.
Input bytes
01001000
01100101
01101100
6-bit indexes
010010
000110
010101
101100
Input bytes
01101100
01101111
6-bit indexes
011011
000110
111100
000000
Alphabet lookup
A 6-bit number can represent values from 0 to 63. Standard Base64 maps those values to uppercase letters, lowercase letters, digits, plus, and slash. Highlighted cells are used by the current input.
Decode direction
Each Base64 character maps back to a 6-bit number. A decoder joins those bits, cuts them into 8-bit bytes, then removes bytes implied only by padding.
010010
000110
010101
101100
011011
000110
111100
padding
Base64 does not change the meaning of bytes. It only rewrites those bytes as printable ASCII characters.
The encoder reads 24 bits at a time, splits them into four 6-bit numbers, then looks up each number in a 64-character alphabet.
Anyone can reverse Base64 without a key. Use it for transport and embedding, not for hiding passwords or secrets.
Where it fits
Binary attachments can move through mail systems that expect text-safe content.
Small images, SVGs, fonts, or other assets can be embedded in HTML and CSS.
Binary fields can travel inside text payloads when an API does not accept raw bytes.
Tokens usually use Base64URL, a URL-safe variant of Base64.
PEM files wrap DER bytes in Base64 plus readable header and footer lines.
Logs and config files often contain encoded bytes that need validation before decoding.
What breaks decoders
A trailing = or == only fills the final 4-character block. Missing padding is often repairable unless the length mod 4 is 1.
JWTs replace + with - and / with _, and often remove padding. Convert the alphabet before using a standard decoder.
Base64 works on bytes. Text must first become bytes, usually UTF-8, before it can be encoded.
Decoded bytes are not always readable text. Images, PDFs, ZIP files, and keys should be handled as bytes.
Use the private browser decoder for text, files, data URIs, Base64URL, images, PDFs, and suspicious padding.
Related guides
Paste a Base64 string and decode it to readable text, bytes, images, PDFs, or downloadable files in your browser without uploading data to a server.
Convert text or files into Base64 strings in your browser, with URL-safe output support and no server-side upload.
Base64URL is a URL-safe variant of Base64 that replaces plus and slash with dash and underscore, and often omits padding.
A quick reference for Base64 characters, URL-safe variants, language code examples, MIME prefixes, and data URI patterns.
Use Python base64.b64decode() to convert Base64 strings back to bytes, then decode those bytes as text or write them to a file.
Use atob() for ASCII Base64 in the browser, then use Uint8Array and TextDecoder when decoded bytes may contain Unicode text.
PHP base64_decode() converts Base64 text back to binary data. Use strict mode when validating untrusted input.
Java uses java.util.Base64 to decode standard, URL-safe, and MIME Base64 into byte arrays that can be converted to strings or files.
Use base64 -d on Linux to decode stdin or files. On macOS, use base64 -D with the BSD command.
A Base64 data URI embeds file bytes directly inside a URL string, commonly for small images, fonts, SVGs, and CSS assets.
Decode Base64 online in a private tool that runs locally in your browser, so pasted values and files stay on your device.