Converting...
Enter text or a Base64 string to encode or decode with full block breakdown.
What Is Base64 and How Does It Work?
Base64 is a binary-to-text encoding scheme that represents binary data as an ASCII string. It was designed to carry data across channels that only reliably support text content, such as email bodies, URLs, JSON payloads, and XML documents. Every 3 bytes of binary data are mapped to 4 ASCII characters from a 64-character alphabet.
The encoding process works by reading the input data in 24-bit groups (3 bytes). Each 24-bit group is then split into four 6-bit chunks, and each 6-bit value is mapped to one of the 64 printable ASCII characters. If the input length is not divisible by 3, one or two padding characters (=) are appended to the output so the total character count is always a multiple of 4.
Our converter automates the entire process and shows a per-block breakdown so you can verify that each 3-byte input group maps to the correct 4-character output. You can also switch between the standard and URL-safe variants, or control padding behavior when encoding.
Base64 Alphabet Table
The Base64 alphabet maps 6-bit values (0-63) to printable ASCII characters. The table below shows the complete alphabet with decimal and binary index values.
| Index | Char | Index | Char | Index | Char | Index | 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 | / |
Standard Base64 vs URL-Safe Base64
Standard Base64 uses the characters + and / at indices 62 and 63. While these are valid in many contexts, they have special meanings in URLs and filesystem paths. The plus sign is interpreted as a space in URL query parameters, and the slash is interpreted as a path delimiter.
URL-safe Base64 solves this by replacing + with - (hyphen) and / with _ (underscore). This variant is defined in RFC 4648 section 5 and is commonly used in JWT tokens, URL parameters, and filenames.
When decoding, it is important to select the same variant that was used for encoding. Decoding a URL-safe string with the standard decoder will produce an error because - and _ are not valid characters in the standard alphabet.
Base64 Padding Explained
Padding ensures that the Base64 output always consists of complete 4-character blocks. Because Base64 converts 3 bytes into 4 characters, the input byte count must be divisible by 3 for the output to need no padding. If the input has 1 remaining byte, two = padding characters are added. If the input has 2 remaining bytes, one = padding character is added.
| Input bytes | Output chars | Padding | Example |
|---|---|---|---|
| 3 | 4 | 0 | Man → TWFu |
| 2 | 4 | 1 | Ma → TWE= |
| 1 | 4 | 2 | M → TQ== |
Common Base64 Use Cases
| Use case | Why Base64? |
|---|---|
| JWT tokens | Header and payload segments are Base64-encoded JSON. |
| Data URIs | Embeds images and fonts directly in CSS or HTML as text. |
| HTTP Basic Auth | Username:password is Base64-encoded in the Authorization header. |
| Email MIME | Binary attachments are encoded as Base64 text in email bodies. |
| URL parameters | URL-safe Base64 encodes binary data in query strings without corruption. |
Frequently Asked Questions
How do you encode text to Base64?
Select the Encode direction, type or paste your text, choose the variant (standard or URL-safe) and padding mode, then click Convert. The tool converts your text to UTF-8 bytes first, then applies Base64 encoding. The result includes a block-by-block breakdown showing exactly how each byte group was converted.
How do you decode a Base64 string?
Select the Decode direction, paste the Base64 string, choose the correct variant, and click Convert. The tool strips any whitespace automatically, validates the characters against the selected alphabet, decodes the bytes, and verifies that the result is valid UTF-8 text.
What is the difference between standard and URL-safe Base64?
Standard Base64 uses + and / as its last two alphabet characters. URL-safe Base64 replaces them with - and _ to avoid conflicts with URL encoding and filesystem paths. Always decode with the same variant used for encoding.
Why does Base64 output end with =?
The = padding characters ensure the output length is always a multiple of 4 characters. They indicate how many bytes were in the final incomplete group: two equals signs mean 1 byte, one equals sign means 2 bytes, and no padding means a complete 3-byte group. Some modern protocols omit padding, which is why our tool supports both modes.
Is Base64 encryption?
No. Base64 is an encoding scheme, not an encryption algorithm. It does not use a key and provides no security. Anyone can decode a Base64 string instantly. Base64 is used for data transport and storage compatibility, not for confidentiality. If you need to protect data, use a proper encryption tool.
Can Base64 contain spaces or newlines?
The Base64 alphabet itself does not include whitespace. However, it is common practice to insert line breaks every 76 characters when embedding Base64 in email or text files (PEM format). Our decoder automatically strips all whitespace before processing, so you can paste Base64 with line breaks without issue.
Related Calculators
Binary to Text Converter
Convert binary code to readable ASCII text and translate text back into binary.
Binary to Decimal Converter
Convert binary integers and fractions to exact decimal values with place-value breakdown.
Hex to Decimal Converter
Convert hexadecimal integers and fractions to exact decimal with binary, octal, and place-value breakdown.
JSON Formatter & Validator
Format, minify, and validate JSON with sorted keys and structural stats.