Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 back to plain text. Supports standard and URL-safe Base64.
All processing happens in your browser. No data is sent to any server.
Try an Example
What is Base64?
Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters. The standard Base64 alphabet consists of uppercase letters A-Z (values 0-25), lowercase letters a-z (values 26-51), digits 0-9 (values 52-61), and two special characters + (value 62) and / (value 63). When the input length is not a multiple of three bytes, the output is padded with one or two = characters to make the encoded output a multiple of four characters.
Base64 encoding works by taking groups of three bytes (24 bits) and splitting them into four 6-bit values, each of which maps to one character in the Base64 alphabet. Because three bytes of input become four characters of output, Base64-encoded data is approximately 33% larger than the original binary data. Despite this size increase, Base64 remains essential for safely transmitting binary data through text-only channels such as email, JSON, XML, and URLs.
Base64 Alphabet
The complete Base64 index table. Each 6-bit value (0-63) maps to one character.
| Value | Char | Value | Char | Value | Char | Value | Char |
|---|---|---|---|---|---|---|---|
| 0 | A | 16 | Q | 32 | g | 48 | w |
| 1 | B | 17 | R | 33 | h | 49 | x |
| 2 | C | 18 | S | 34 | i | 50 | y |
| 3 | D | 19 | T | 35 | j | 51 | z |
| 4 | E | 20 | U | 36 | k | 52 | 0 |
| 5 | F | 21 | V | 37 | l | 53 | 1 |
| 6 | G | 22 | W | 38 | m | 54 | 2 |
| 7 | H | 23 | X | 39 | n | 55 | 3 |
| 8 | I | 24 | Y | 40 | o | 56 | 4 |
| 9 | J | 25 | Z | 41 | p | 57 | 5 |
| 10 | K | 26 | a | 42 | q | 58 | 6 |
| 11 | L | 27 | b | 43 | r | 59 | 7 |
| 12 | M | 28 | c | 44 | s | 60 | 8 |
| 13 | N | 29 | d | 45 | t | 61 | 9 |
| 14 | O | 30 | e | 46 | u | 62 | + |
| 15 | P | 31 | f | 47 | v | 63 | / |
Padding character: = (used when input byte count is not a multiple of 3)
Common Uses for Base64
- Email attachments (MIME) — Binary files are Base64-encoded so they can be transmitted as ASCII text in email protocols.
- Data URIs in HTML/CSS — Small images and fonts can be embedded directly in markup using
data:image/png;base64,...URIs. - JSON Web Tokens (JWT) — JWTs use URL-safe Base64 (base64url) to encode the header, payload, and signature sections.
- HTTP Basic Authentication — Credentials are encoded as
base64(username:password)in the Authorization header. - API keys and tokens — Many services issue API keys that are Base64-encoded binary values for safe transport in HTTP headers.
- Storing binary data in JSON/XML — Since JSON and XML are text formats, binary blobs must be Base64-encoded before embedding.
Base64 vs URL-Safe Base64
Standard Base64 uses + and / as the 62nd and 63rd characters in its alphabet. However, both of these characters have special meaning in URLs: + is interpreted as a space, and / is a path separator. This makes standard Base64 unsafe for use directly in URLs and filenames.
URL-safe Base64 (also called base64url, defined in RFC 4648) solves this by replacing + with - (hyphen) and / with _ (underscore). Additionally, the = padding is often omitted since the original length can be inferred. URL-safe Base64 is used extensively in JWTs, OAuth tokens, and anywhere encoded data appears in URLs or filenames.
| Feature | Standard Base64 | URL-Safe Base64 |
|---|---|---|
| Character 62 | + | - (hyphen) |
| Character 63 | / | _ (underscore) |
| Padding | Required (=) | Optional |
| RFC | RFC 4648 sec. 4 | RFC 4648 sec. 5 |