+ and /, while the URL-safe variant uses - and _. Paste your text below to encode it, or paste a Base64 string to decode it. Encoding is fully reversible and is not encryption.
| Property | Value |
|---|
Base64 quick-reference table
Canonical examples from RFC 4648 plus everyday strings. Each row is computed live by the same encoder used above.
| Input text | UTF-8 bytes | Standard Base64 | Padding |
|---|
What Is Base64 Encoding?
Base64 is a binary-to-text encoding scheme. It takes a sequence of arbitrary bytes and rewrites them using only 64 safe, printable ASCII characters. Because the output contains no control characters, no quotes and no non-ASCII bytes, it can be embedded in places that were designed for plain text: email bodies, JSON string values, XML attributes, HTML attributes, URL query parameters and configuration files.
The name comes from the size of the alphabet. Each output character carries exactly 6 bits of information because 2 to the power of 6 equals 64. A normal byte carries 8 bits, so the encoder groups input bytes into 24-bit triples and splits each triple into four 6-bit values. Those four values are then looked up in the alphabet table.
Base64 is defined by RFC 4648, which also standardises Base32 and Base16 (hex). It is a reversible transformation: decoding always returns the exact original bytes, and no key is involved. That is why it is classified as an encoding rather than a cipher.
The Base64 Alphabet and the Encoding Formula
Index 0 maps to uppercase A, index 25 maps to Z, index 26 maps to lowercase a, index 51 maps to z, index 52 maps to the digit 0, index 61 maps to 9, index 62 maps to plus, and index 63 maps to slash. The equals sign is reserved for padding and is not part of the 64-character alphabet.
| Index range | Characters | Bit width |
|---|---|---|
| 0 to 25 | A to Z | 6 bits each |
| 26 to 51 | a to z | 6 bits each |
| 52 to 61 | 0 to 9 | 6 bits each |
| 62 | + (- in Base64URL) | 6 bits |
| 63 | / (_ in Base64URL) | 6 bits |
| Padding only | = | Not data |
The formula in plain arithmetic
For a triple of bytes b0, b1 and b2, the four output indices are:
i0 = b0 >> 2i1 = ((b0 & 3) << 4) | (b1 >> 4)i2 = ((b1 & 15) << 2) | (b2 >> 6)i3 = b2 & 63
Decoding reverses the shifts and masks. The tool above applies these operations byte by byte to the UTF-8 representation of your input.
Padding rules
Input length is rarely an exact multiple of three bytes. If only one byte remains in the final group, the encoder emits two data characters followed by two equals signs. If two bytes remain, it emits three data characters followed by one equals sign. If the length is a multiple of three, no padding is added.
| Remaining bytes | Data characters | Padding | Example input | Example output |
|---|---|---|---|---|
| 3 | 4 | none | Man | TWFu |
| 2 | 3 | = | Ma | TWE= |
| 1 | 2 | == | M | TQ== |
Size Overhead and Line Wrapping
Three bytes become four characters, so the expansion factor is exactly 4/3, or a 33.3% increase before any line breaks. For n input bytes the padded output length is 4 x ceil(n / 3) characters. If the encoder inserts a newline every 76 characters, add roughly floor(length / 76) extra characters.
| Input bytes | Base64 characters | Overhead | With 76-character wrapping |
|---|---|---|---|
| 1 | 4 | 300.0% | 4 |
| 3 | 4 | 33.3% | 4 |
| 9 | 12 | 33.3% | 12 |
| 57 | 76 | 33.3% | 76 |
| 60 | 80 | 33.3% | 81 |
| 1024 | 1368 | 33.6% | 1385 |
MIME email encoding, described in RFC 2045, wraps Base64 at 76 characters. PEM certificate blocks commonly use 64 characters. This tool lets you choose either width or no wrapping at all; the decoder ignores every whitespace character, so wrapped input still decodes correctly.
Standard Base64 vs. Base64URL vs. Base32
| Variant | Characters 62 and 63 | Padding | Typical use |
|---|---|---|---|
| Standard Base64, RFC 4648 section 4 | + and / | Required, = | Email, JSON, XML, data URIs |
| Base64URL, RFC 4648 section 5 | - and _ | Usually omitted | URLs, JWT segments, cookies, file names |
| Base32, RFC 4648 section 6 | Uppercase letters and digits 2 to 7 | = | Case-insensitive keys and TOTP secrets |
| Base16, RFC 4648 section 8 | Hex digits 0 to 9 and A to F | None | Byte dumps, hashes, colour codes |
The plus sign has a special meaning in URL query strings and the slash is a path separator, which is why the URL-safe alphabet substitutes them. Auto detect in this tool looks for a hyphen or underscore and switches alphabet accordingly.
Worked Examples
| Goal | Input | Result | Why |
|---|---|---|---|
| Encode an ASCII word | Man | TWFu | Three bytes map exactly to four characters with no padding. |
| Encode two bytes | Ma | TWE= | The final group holds two bytes, so one equals sign is added. |
| Encode one byte | M | TQ== | The final group holds one byte, so two equals signs are added. |
| Decode a greeting | SGVsbG8sIHdvcmxkIQ== | Hello, world! | Thirteen UTF-8 bytes decode back to thirteen ASCII characters. |
| Encode a non-ASCII letter | cafe with an e acute | Two UTF-8 bytes for the accented letter | Base64 encodes bytes, so U+00E9 becomes C3 A9 before encoding. |
| Convert hex | 4d616e | TWFu | The hex bytes 4D 61 6E are the ASCII letters M, a, n. |
To verify any result, copy the encoded output into the Decode tab. A correct round trip returns the original text byte for byte. If the decoded bytes are not valid UTF-8, choose the hex view instead so you can inspect the raw values.
UTF-8 and Why Base64 Encodes Bytes, Not Characters
Base64 has no concept of letters, only bytes. A character such as an accented letter, a Chinese ideograph or an emoji is first converted to its UTF-8 byte sequence as specified in RFC 3629. A single visible character may therefore occupy two, three or four bytes, and each of those bytes contributes to the encoded length.
This is the most common source of confusion. Two Base64 strings that look identical may decode to different text if one was produced from UTF-8 bytes and the other from a legacy single-byte encoding. When decoding, this tool validates the byte stream strictly: overlong sequences, stray continuation bytes, surrogate code points and values above U+10FFFF are rejected with a clear message instead of producing replacement characters.
Data URIs and Everyday Uses
- Data URIs, RFC 2397: a small image, font or file can be embedded as
data:image/png;base64,.... The Inspector tab reports the declared MIME type, size and file signature. - Email attachments: MIME uses Base64 so that binary attachments survive transport through text-only mail relays.
- APIs and JSON: binary fields, uploaded thumbnails and cryptographic nonces are usually carried as Base64 strings.
- Web authentication: Basic authentication headers and the header and payload segments of JSON Web Tokens use Base64URL.
- Configuration files: keys, certificates and encoded credentials are stored as single-line Base64 values in YAML, TOML and environment variables.
If you work with other encodings, the Morse Code Translator handles a classic character-level code, while the Number Base Converter shows how the same value looks in binary, octal, decimal and hex.
Common Mistakes
- Treating Base64 as encryption. It is trivially reversible and offers zero secrecy.
- Forgetting the UTF-8 step. Encoding a JavaScript string without converting it to bytes first corrupts any non-ASCII character.
- Mixing alphabets. A plus or slash in a URL-safe context, or a hyphen in a standard context, causes an invalid-character error.
- Removing padding incorrectly. Unpadded output is legal in many protocols, but the length must never be one more than a multiple of four.
- Confusing Base64 with hex. Hex uses 16 symbols and two characters per byte; Base64 uses 64 symbols and four characters per three bytes.
- Ignoring size growth. A 10 MB file becomes roughly 13.3 MB of text, which matters for payload limits and databases.
- Pasting HTML-escaped text. An ampersand written as an entity is not the same byte sequence as a plain ampersand.
Key Takeaways
- Base64 maps 3 bytes to 4 printable characters and grows data by about 33.3%.
- It is an encoding, not encryption, and requires no key to reverse.
- Padding with equals signs only appears when the byte count is not a multiple of three.
- Base64URL swaps plus and slash for hyphen and underscore so the result is safe in URLs.
- Always convert text to UTF-8 bytes before encoding, and validate bytes before decoding to text.
- Whitespace and line breaks are ignored by the decoder, so 76-character MIME wrapping is harmless.
Authoritative References
- RFC 4648, The Base16, Base32, and Base64 Data Encodings.
- RFC 2045, Multipurpose Internet Mail Extensions Part One, section 6.8 on Base64 Content-Transfer-Encoding.
- RFC 3629, UTF-8, a transformation format of ISO 10646.
- RFC 2397, The data URL scheme.
- W3C File API and HTML specification notes on binary-to-text handling in browsers.
Last updated: December 5, 2026 · All conversions are performed locally in your browser. No data is stored or transmitted.
Base64 Encoder and Decoder FAQ
Base64 converts binary bytes into a string of 64 printable ASCII characters so that data can travel safely through systems that only handle text, such as email headers, JSON documents and HTML attributes.
No. Base64 is an encoding, not encryption. Anyone can reverse it without a key, so it provides no confidentiality and should never be used to protect passwords or secrets.
Every three input bytes become four output characters, so the encoded text is about 33.3 percent larger than the original bytes before any line breaks are added.
The equals sign is padding. It is added when the input byte count is not a multiple of three: one equals sign means two bytes in the final group, and two equals signs mean one byte in the final group.
Base64URL replaces the plus sign with a hyphen and the slash with an underscore, and usually omits padding, so the result is safe inside URLs, cookies and file names. The encoding algorithm is otherwise identical.
Encode the text as UTF-8 bytes first, then decode those bytes as Base64. This tool performs the UTF-8 conversion for you and reports an error when the bytes are not valid UTF-8.
Common causes are an invalid character, a length that is one more than a multiple of four, misplaced padding, or confusing standard Base64 with Base64URL. Switch the alphabet option or remove stray characters and try again.
No. All encoding and decoding runs locally in your browser with JavaScript. Nothing is sent to a server, stored, or logged.