Everything you need to know about Base64 encoding and decoding. Understand radix-64 math, binary-to-ASCII conversion, padding rules, and performance impacts.
Calculate your numbers instantly in your browser. Fast, free, no signup.
Base64 is a binary-to-text encoding algorithm that translates arbitrary binary sequences or non-ASCII characters into an ASCII string format. It represents binary data using a set of 64 printable characters, ensuring data remains intact without modification during transit across network protocols designed strictly for plain text.
From embedding inline images in HTML/CSS to formatting authentication credentials in HTTP headers, Base64 is a ubiquitous building block of modern web infrastructure.
Historically, legacy communication channels like email (SMTP) and early network gateways were designed to handle only 7-bit US-ASCII text. When raw 8-bit binary data (such as compiled executables, images, or compressed archives) traversed these networks, intermediary routers frequently misinterpreted or stripped byte sequences like control codes or line endings (\r, \n).
Base64 solves this by mapping every possible combination of bits strictly to characters universally supported across all systems:
A-Z (indices 0–25)a-z (indices 26–51)0-9 (indices 52–61)+ and / (indices 62–63)The algorithm groups binary input into chunks of 24 bits (3 bytes of 8 bits each) and re-slices them into four 6-bit units:
Input (3 Bytes): [ Byte 1 (8b) ] [ Byte 2 (8b) ] [ Byte 3 (8b) ]
Total Bits: |------------------ 24 bits -------------------|
Regrouping (4x 6b): [ 6 bits ] [ 6 bits ] [ 6 bits ] [ 6 bits ]
Base64 Index: (0 to 63) (0 to 63) (0 to 63) (0 to 63)
Mapped ASCII: Char 1 Char 2 Char 4 Char 4
Because 3 bytes (24 bits) of raw data produce 4 bytes (32 bits) of encoded ASCII text, Base64 encoding always increases data size by approximately 33%:
Encoded Size ≈ ceil(n / 3) × 4 bytes
= Padding Character?What happens if the input byte sequence is not evenly divisible by 3?
= padding characters (==).= character.Authorization header take the format Basic base64(username:password).data:image/png;base64,... to eliminate extra HTTP round trips.Base64URL, which substitutes - and _ for + and /).Test your strings or decode payloads directly in our client-isolated Base64 Encoder & Decoder.