# Base64 Encode & Decode

Type or paste text to encode it as Base64, or switch to Decode to turn Base64 back into text. The example “Hello, 世界 👋” is 18 bytes in UTF-8 and becomes 24 characters: SGVsbG8sIOS4lueVjCDwn5GL. Emoji, Hebrew, Chinese and every other script are handled correctly, because text is converted to UTF-8 bytes first. Choose standard or URL-safe Base64, with or without “=” padding, and optional 76-character MIME lines. Decoding ignores spaces and line breaks, accepts missing padding, detects the URL-safe form and points at the first invalid character. You can also turn a file (up to 10.0 MB) into Base64 or a data: URL. Nothing you enter is uploaded.

Canonical page: https://ponderloop.com/tools/base64-encode-decode/
Updated: 2026-10-03

## How to use

How to encode or decode Base64

1. **Choose a direction**: Pick “Encode text to Base64” to convert text, or “Decode Base64 to text” to read Base64 you have.
2. **Paste your input**: Replace the example with your own text or Base64. The result appears as you type.
3. **Pick the Base64 form**: For encoding, choose standard or URL-safe, turn “=” padding on or off and add 76-character lines if you need MIME. Decoding detects all of this by itself.
4. **Copy the result**: Copy the output, or use “Use result as input” to switch direction and check the round trip.
5. **Convert a file if you need to**: Choose a file under 10.0 MB to get its Base64 or a ready-made data: URL. The file is read on your device only.

## Reference tables and worked examples

### The Base64 alphabet

Each Base64 character stands for 6 bits, a value from 0 to 63. URL-safe Base64 differs only in the last two (62 and 63). The “=” sign is padding, not a value.

| Values | Standard (RFC 4648 §4) | URL-safe (RFC 4648 §5) |
| --- | --- | --- |
| 0–15 | A B C D E F G H I J K L M N O P | A B C D E F G H I J K L M N O P |
| 16–31 | Q R S T U V W X Y Z a b c d e f | Q R S T U V W X Y Z a b c d e f |
| 32–47 | g h i j k l m n o p q r s t u v | g h i j k l m n o p q r s t u v |
| 48–63 | w x y z 0 1 2 3 4 5 6 7 8 9 + / | w x y z 0 1 2 3 4 5 6 7 8 9 - _ |
| padding | = | = (often left out) |

### Examples

Text, its UTF-8 bytes in hex, and the Base64 this tool produces. Man, Ma and M show how padding fills the last group of four.

| Text | UTF-8 bytes (hex) | Standard Base64 | URL-safe, no padding |
| --- | --- | --- | --- |
| Man | 4d 61 6e | TWFu | TWFu |
| Ma | 4d 61 | TWE= | TWE |
| M | 4d | TQ== | TQ |
| Hello | 48 65 6c 6c 6f | SGVsbG8= | SGVsbG8 |
| ???>>> | 3f 3f 3f 3e 3e 3e | Pz8/Pj4+ | Pz8_Pj4- |
| café | 63 61 66 c3 a9 | Y2Fmw6k= | Y2Fmw6k |
| שלום | d7 a9 d7 9c d7 95 d7 9d | 16nXnNeV150= | 16nXnNeV150 |
| 世界 | e4 b8 96 e7 95 8c | 5LiW55WM | 5LiW55WM |
| 👋 | f0 9f 91 8b | 8J+Riw== | 8J-Riw |

### How much bigger Base64 gets

Every 3 bytes become 4 characters, so the encoded form is about 4/3 the size (+33%). Line breaks add a little more.

| Input bytes | Base64 characters | Increase | With 76-character lines |
| --- | --- | --- | --- |
| 1 | 4 | +300% | 4 |
| 2 | 4 | +100% | 4 |
| 3 | 4 | +33% | 4 |
| 10 | 16 | +60% | 16 |
| 100 | 136 | +36% | 137 |
| 1,000 | 1,336 | +34% | 1,353 |
| 1,000,000 | 1,333,336 | +33% | 1,350,879 |

## How it works

Encoding turns text into UTF-8 bytes with TextEncoder, then takes the bytes three at a time (24 bits) and splits them into four 6-bit values, each looked up in the 64-character alphabet. A last group of one or two bytes yields two or three characters, followed by “=” when padding is on. URL-safe output swaps the characters for values 62 and 63. MIME output breaks the text every 76 characters, using plain line feeds. Decoding first strips an optional data: URL prefix and ignores whitespace, then maps each character back to 6 bits, accepting either alphabet but not both in one text, and treats “=” only as trailing padding (missing padding is fine). A count of characters that leaves a single extra character cannot come from any byte sequence and is reported as incomplete. The bytes are decoded as strict UTF-8 with TextDecoder; if that fails, a hex preview is shown instead of replacement characters. Files are read with FileReader into memory, encoded the same way and kept only on the page.

## FAQ

### What is Base64?

Base64 writes any bytes using only 64 safe characters (A–Z, a–z, 0–9, + and /), so binary data can travel through systems built for text, such as email, JSON, HTML, CSS and URLs. It is an encoding, not encryption: anyone can decode it.

### Does it work with emoji, Hebrew and Chinese?

Yes. Text is first converted to UTF-8 bytes with the browser’s TextEncoder, and those bytes are encoded. The browser’s plain btoa() function fails on any character above U+00FF, which is why many online tools break on emoji. Decoding reverses the steps with TextDecoder.

### What is URL-safe Base64?

It replaces “+” with “-” and “/” with “_”, because the standard characters have special meanings in URLs and file names. It is used in JWTs, many APIs and filenames, and usually leaves out the “=” padding. This tool decodes either form without being told which.

### Why does Base64 end with = signs?

Base64 works in groups of 3 bytes that become 4 characters. When the data does not fill the last group, one or two “=” fill it up so the length is a multiple of 4. Many systems accept it without the padding, and this tool does too when decoding.

### Why does decoding say my bytes are not valid UTF-8?

Base64 can hold anything: images, PDFs, compressed or encrypted data. When the decoded bytes are not valid UTF-8 text, showing them as characters would only produce garbage, so the tool shows the first bytes in hex instead, and names the file type when it recognises it (PNG, JPEG, GIF, PDF, ZIP, gzip).

### What does “invalid character at position” mean?

Base64 uses only letters, digits, “+” and “/” (or “-” and “_”), plus “=” at the end. Spaces and line breaks are ignored, but any other character, such as a quote, a comma or an accented letter, stops decoding. The position counts every character you typed, starting at 1, so you can find it in your text.

### How do I Base64 encode a file or an image?

Use the file section: choose a file up to 10.0 MB and copy its Base64, or copy a data: URL such as data:image/png;base64,… to paste into HTML or CSS. The file is read by your browser and never uploaded.

### Why is the Base64 text longer than the original?

Each 3 bytes become 4 characters, so the output is about 33% larger (a little more with padding on very short input, and with line breaks). The table above shows exact sizes.

### Is my text or file saved or sent anywhere?

No. Encoding and decoding run in your browser, nothing is uploaded, and the text is not saved: reload the page and it is gone. The only thing the site records, if you allow analytics, is that a button was used, never any of your text or files.

## Sources

- [RFC 4648: The Base16, Base32, and Base64 Data Encodings](https://www.rfc-editor.org/rfc/rfc4648)
- [RFC 2045 §6.8: Base64 Content-Transfer-Encoding (MIME, 76-character lines)](https://www.rfc-editor.org/rfc/rfc2045#section-6.8)
- [RFC 2397: The “data” URL scheme](https://www.rfc-editor.org/rfc/rfc2397)
- [MDN: Base64 encoding and decoding (btoa and Unicode strings)](https://developer.mozilla.org/en-US/docs/Glossary/Base64)
- [MDN: TextEncoder and TextDecoder](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder)

---

Cite as: Base64 Encode & Decode, ponderloop, https://ponderloop.com/tools/base64-encode-decode/, updated 2026-10-03
