---
slug: base64-encoder-decoder-calculator
title: "Base64 Encoder Decoder Calculator"
category: developer
updated: 2026-11-17
canonical: https://calcseed.com/c/developer/base64-encoder-decoder-calculator/
html: /c/developer/base64-encoder-decoder-calculator/
---

# Base64 Encoder Decoder Calculator

Encode text to Base64 or decode Base64 back into readable text. Handles Unicode safely and shows the result instantly, for free.

## Formula

```text
output length = 4 × &lceil;input bytes ÷ 3&rceil;    each 3 bytes &rarr; 4 characters
```

## Inputs

| Variable | Type | Unit | Default |
| --- | --- | --- | --- |
| Mode | select |  | encode |
| Input | text |  | Hello, world! |

## Outputs

| Result | Format |
| --- | --- |
| Result | primary |
| Result | text |

## How it works

### What the tool returns

Paste text in encode mode and the tool returns the Base64 string; switch to decode and it turns a Base64 string back into text. The default **Hello, world!** is 13 bytes and encodes to **SGVsbG8sIHdvcmxkIQ==**, which is 20 characters. Text is converted to UTF-8 bytes first, so accented letters and emoji survive the round trip instead of turning into mojibake.

### Why three bytes become four characters

Base64 works on bits, not characters. Three bytes are 24 bits, and 24 divides evenly by 6, so the encoder cuts those bits into four groups of six. Each group of six addresses one of 64 symbols, which is where the name comes from: 2^6 = 64.

The 4/3 ratio is the whole cost of the encoding. Six bits of payload fit in one printable character, but a character in a text channel normally carries 8 bits, so the output is larger than the input by a third. That expansion is the price of moving arbitrary bytes through a channel that only accepts a safe subset of ASCII.

Length is always a multiple of four, because the encoder pads the last group. One leftover byte becomes two characters plus `==`, and two leftover bytes become three characters plus `=`. The formula 4 × &lceil;n ÷ 3&rceil; captures both the grouping and the padding in one expression.

#### The 64 symbols

| Index | Character | Index | Character |
| --- | --- | --- | --- |
| 0–25 | A–Z | 52–61 | 0–9 |
| 26–51 | a–z | 62 | + |
|  |  | 63 | / |
| Padding | = |  |  |

The alphabet is ordered by ASCII value, which is why the mapping looks arbitrary but is easy to compute: subtract 65 for uppercase, 97 for lowercase and 48 for digits. The two extra symbols are plus and slash because they sit next to the letters in ASCII and are safe in most transport contexts, though not in a URL without escaping.

### Worked example: Hel to SGVs

Take the first three bytes of the default, H, e and l, which are 72, 101 and 108. In binary: 01001000 01100101 01101100. Concatenate to 010010000110010101101100 and regroup into four 6-bit chunks: 010010, 000110, 010101, 101100.

Convert each chunk to decimal: 18, 6, 21 and 44. Index 18 is S, 6 is G, 21 is V and 44 is s, so the first four characters are SGVs. The remaining groups follow the same pattern: lo, gives bG8s, space-wo gives IHdv, rld gives cmxk, and the final lone exclamation mark gives IQ==

String the five groups together and you get SGVsbG8sIHdvcmxkIQ==. Count the characters: 20, which matches 4 × &lceil;13 ÷ 3&rceil; = 4 × 5. Decoding runs the same steps backward, reassembling 24-bit groups and discarding the padding.

### How much does Base64 inflate a payload

| Input | Base64 length | Inflation |
| --- | --- | --- |
| 1 byte | 4 chars (2 padding) | 400% |
| 2 bytes | 4 chars (1 padding) | 200% |
| 3 bytes | 4 chars | 133% |
| 13 bytes | 20 chars (2 padding) | 154% |
| 100 bytes | 136 chars | 136% |
| 1 MB | 1,398,104 chars | 133% |

Small inputs look terrible because the padding dominates: a single byte expands fourfold. Above about 100 bytes the padding becomes negligible and the ratio settles at 133%, so 1 MB of binary becomes 1.33 MB of text. That extra third is why Base64 is a transport encoding, not a storage format.

### Where Base64 shows up

- Email attachments, where MIME wraps Base64 at 76 characters per line and the line breaks are not part of the data
- JSON and XML fields that must carry a file or a key as text, since raw bytes are not valid in either
- Data URIs in CSS and HTML, such as an inline PNG written as data:image/png;base64,
- Basic authentication headers, where user:password is Base64 encoded rather than encrypted
- JWT segments, where the header and payload are Base64URL encoded and only the signature is protected

The authentication case is the one that misleads people. A Basic auth header decodes instantly to the original credentials, so it offers no protection at all unless the connection is already encrypted with TLS. The same applies to a JWT payload: anyone holding the token can read the claims, and only the signature stops them changing them.

#### Standard versus URL-safe alphabet

The standard alphabet uses + and /, which have meaning in a URL and can be mangled by form encoders. The URL-safe variant swaps them for − and _, and often drops the padding. The two are not interchangeable: a string encoded with one alphabet will decode to garbage or throw with the other. If a token contains a hyphen or underscore, it is almost certainly Base64URL and needs the matching decoder.

### Common mistakes

- Treating Base64 as encryption: it is reversible by anyone, with no key involved
- Forgetting that line breaks in MIME output are formatting, not data, and pasting them into a strict decoder
- Mixing the standard and URL-safe alphabets, which produces a decode error or silent corruption
- Encoding a string that was already Base64, which doubles the length and hides the original
- Assuming the decoded length equals the encoded length divided by four, which ignores padding and rounding
- Passing invalid characters such as spaces or quotes, which make the decoder throw rather than skip them

### Padding rules in detail

Padding exists so the output length stays a multiple of four, which lets decoders work in fixed 4-character blocks. One trailing byte produces two data characters and `==`; two trailing bytes produce three data characters and a single `=`. A decoder that sees the wrong number of padding characters can reject the string, so do not hand-edit them.

Some systems omit padding entirely and expect the decoder to infer the missing bytes from the length. That works when the length modulo four is 2 or 3, and fails when it is 1, since one leftover character cannot represent a whole byte. If a decoder complains about an invalid length, check for a stripped trailing equals sign before looking anywhere else.

#### Unicode and the byte count

The encoder converts text to UTF-8 before encoding, so the byte count is not the character count. A single emoji is four UTF-8 bytes and therefore six Base64 characters once you account for the group it lands in, while an ASCII letter is one byte and roughly 1.33 characters. That is why a string of ten emoji encodes to 56 characters rather than the 14 a naive character count would predict.

## FAQ

### Is Base64 encryption?

No. Base64 is an encoding, not encryption. Anyone can decode it with no key, so a password hidden in Base64 is readable in one step. Use TLS for transit and a real cipher for storage.

### Why does Base64 end with equals signs?

Equals signs are padding added when the input length is not a multiple of three bytes, so the output stays a multiple of four characters. One leftover byte gives ==, two give =.

### Can Base64 handle emoji?

Yes, because the text is converted to UTF-8 bytes before encoding. One emoji is 4 bytes, which becomes 6 Base64 characters plus whatever padding the group needs.

### How long is Hello, world! in Base64?

20 characters: SGVsbG8sIHdvcmxkIQ==. The input is 13 bytes, and 4 × &lceil;13 ÷ 3&rceil; = 20.

### How much larger does Base64 make a file?

About 33% for anything over a few hundred bytes. 1 MB becomes 1,398,104 characters, and a 100-byte input becomes 136 characters.

### Why does my Base64 string have line breaks?

MIME encoding wraps at 76 characters for email transport. The breaks are formatting, not data, and most decoders ignore them, but strict ones reject them, so strip the whitespace first.

### What is the difference between Base64 and Base64URL?

Base64 uses + and / while Base64URL uses − and _, and Base64URL often omits padding. Strings encoded with one alphabet will not decode correctly with the other.

### Can I decode a JWT payload?

Yes. The header and payload are Base64URL encoded, so decoding them reveals the claims. That also means the contents are not secret; only the signature prevents tampering.

### Why is a 1-byte input 4 characters instead of 2?

Padding fills the group to four characters. One byte produces two 6-bit characters plus ==, so the length is 4 even though only 12 of the 24 bits carry data.

### Does Base64 reduce file size?

Never. It always increases size, by 33% at steady state and up to 300% for a single byte. If you need smaller output, compress the data first and then encode it.

## Method and sources

Methodology: Conversions and formats follow the relevant IETF RFCs and IEEE standards, including RFC 4648 for Base64 and RFC 791 for IPv4 addressing.

Last updated: 2026-11-17.
- RFC 4648: The Base16, Base32, and Base64 Data Encodings.
