Base64 Encoder & Decoder
Encode text or hex bytes to Base64 and decode Base64 back to text or bytes. It supports the URL-safe alphabet, optional padding and 76-character MIME line wrapping, and shows how the bits map to characters.
Written by Suhaib Hassan. Figures are estimates you can edit. Our methodology.
It converts your input to UTF-8 bytes and maps every 6 bits to a character of the Base64 alphabet, following RFC 4648.
Developers hit Base64 in tokens, headers, data URIs and email. This lets you check a value and see how it is built.
—
| Character | Index | 6 bits |
|---|
The Base64 alphabet
Base64 uses 64 printable characters. Three bytes (24 bits) become four characters of 6 bits each. If the input is not a multiple of three bytes, = padding fills the last group.
| Index | Standard (RFC 4648 §4) | URL-safe (§5) |
|---|---|---|
| 0 to 25 | A to Z | A to Z |
| 26 to 51 | a to z | a to z |
| 52 to 61 | 0 to 9 | 0 to 9 |
| 62 | + | − (hyphen) |
| 63 | / | _ (underscore) |
| Padding | = | = or omitted |
Formulas
How the numbers are worked out.
Three bytes to four characters
Bytes are read as a stream of bits and cut into 6-bit groups, each mapped to one alphabet character.
24 bits = 3 bytes = 4 charactersOutput length
Every 3 input bytes give 4 characters, rounded up, with padding to fill.
length = 4 × ceil(bytes ÷ 3)
overhead ≈ 33%Padding
One leftover byte adds ==, two leftover bytes add =.
bytes mod 3 = 1 → "==", = 2 → "=", = 0 → noneWorked examples
Illustrative figures, each checked by hand. The first is the default setup.
Short text
Encode "Man".
Padding
Encode "Ma" (two bytes).
Default
Encode "Hello, CalculatePilot!" (22 bytes).
How to encode and decode Base64
- Choose Encode or Decode.
- Paste your text, or hex bytes.
- Set the URL-safe, padding and line wrapping options.
- Copy the output, or use it as the next input to check a round trip.
Base64 is an encoding, not encryption. Anyone can decode it, so never use it to hide secrets.
By Suhaib Hassan · Reviewed 29 September 2026 · How CalculatePilot verifies formulas →
Sources
- IETF, RFC 4648, The Base16, Base32, and Base64 Data Encodings (2006).
- IETF, RFC 2045, MIME Part One, section 6.8.
- IETF, RFC 7515, JSON Web Signature, Base64url without padding.
Frequently asked questions
What is Base64 used for?
Carrying binary data through text-only systems, such as email attachments, data URIs, JSON tokens (JWT) and HTTP Basic authentication headers.
Is Base64 encryption?
No. It only re-writes bytes with a different alphabet. Anyone can decode it.
Why does the output end with =?
Padding. Base64 works in groups of 3 bytes. When the input is not a multiple of 3, one or two = characters complete the last group.
What is URL-safe Base64?
A variant that uses - and _ instead of + and /, so it can sit in URLs and file names. JWTs also leave off the = padding.
Why is the output bigger?
Every 3 bytes become 4 characters, about 33% larger, plus line breaks if you wrap lines.
Related calculators
More everyday tools.