Base64 Encoder and Decoder
- Updated
- Formula shown
- Free, no sign-up
Results
Encoded 18 UTF-8 bytes as 24 Base64 characters
SGVsbG8sIGNhZsOpISDwn5iA
Everything is converted in your browser and nothing is uploaded. What you type is also written into this page’s address so the link can be shared (a link restores only the first 2,000 characters), so avoid pasting passwords, tokens or other secrets.
Convert a file to Base64
Choose a file to convert. It stays on your device: it is read by this page and never uploaded.
How to use the Base64 encoder and decoder
- Choose Encode to Base64 or Decode Base64.
- Type or paste your text (up to 50,000 characters). The result updates as you type.
- For encoding, pick the alphabet, padding and line breaks your system expects. Decoding detects the alphabet and ignores spaces and line breaks.
- Press Copy. For images and other files (up to 5 MB), use the file converter under the main tool.
Everything runs in your browser and nothing is uploaded. The text you type is not added to the page address, share links or saved calculations (only your settings are), so copy the result to pass it on. Even so, don't paste passwords, API keys or tokens into any web page you don't control.
How Base64 encoding works
0–25 → A–Z 26–51 → a–z 52–61 → 0–9 62 → + (or -) 63 → / (or _)
encoded length = 4 × ⌈bytes ÷ 3⌉ characters with padding
Base64, defined in RFC 4648, turns any bytes into 64 safe printable characters so binary data can travel through systems built for text: email attachments, JSON, HTML and CSS data URIs, and HTTP headers. Each character carries 6 bits, so three bytes become four characters and the result is about a third larger. When the input isn't a multiple of 3 bytes, the last group is padded with one or two = signs. Text is first turned into bytes as UTF-8, where plain ASCII letters take one byte and accents and emoji take two to four.
Worked example: "Man"
The letters M, a and n are the bytes 77, 97, 110, or 01001101 01100001 01101110 in binary. Regrouped into
6-bit pieces that is 010011 010110 000101 101110, the numbers 19, 22, 5, 46, which are the characters
TWFu. Decoding reverses the steps. An invalid input, such as SGVsbG8!, is rejected with a reason:
"!" at position 8 is not a Base64 character. Base64 uses A–Z, a–z, 0–9 and + / (or - _ for URL-safe), with = only as padding at the end.
RFC 4648 test vectors
| Text | Standard Base64 | URL-safe, no padding |
|---|---|---|
f | Zg== | Zg |
fo | Zm8= | Zm8 |
foo | Zm9v | Zm9v |
foob | Zm9vYg== | Zm9vYg |
fooba | Zm9vYmE= | Zm9vYmE |
foobar | Zm9vYmFy | Zm9vYmFy |
UTF-8 characters in Base64
| Character | UTF-8 bytes | Base64 |
|---|---|---|
| A | 1 | QQ== |
| é | 2 | w6k= |
| € | 3 | 4oKs |
| 😀 | 4 | 8J+YgA== |
The browser's built-in btoa() only accepts characters up to U+00FF, so it fails on "€" and emoji. This tool encodes the UTF-8 bytes
instead, which is what most programming languages and APIs expect.
Encoded size
| Bytes in | Characters (padded) | Characters (no padding) |
|---|---|---|
| 1 | 4 | 2 |
| 2 | 4 | 3 |
| 3 | 4 | 4 |
| 10 | 16 | 14 |
| 100 | 136 | 134 |
| 1,000 | 1,336 | 1,334 |
| 1,000,000 | 1,333,336 | 1,333,334 |
Standard or URL-safe?
- Standard (+ /) is used in email (MIME), PEM certificates and most data URIs. MIME wraps lines at 76 characters and PEM at 64.
- URL-safe (- _) replaces + and /, which have special meanings in URLs and file names. JSON Web Tokens use it without padding. The bytes fb ef be encode as
++++or----. - Base64 is not encryption. Anyone can decode it, so never use it to hide passwords or personal data.
To make text safe for a link instead, use the URL encoder and decoder. For number bases, try the binary calculator or the hex calculator.
Frequently asked questions
What is Base64 encoding?
A way to write any bytes using 64 printable characters (A–Z, a–z, 0–9, + and /), defined in RFC 4648. Every 3 bytes become 4 characters, so "Man" encodes as TWFu. It lets binary data such as images travel through text-only systems like email, JSON and HTML.
Why does Base64 make data bigger?
Each character carries only 6 of a byte’s 8 bits, so 3 bytes need 4 characters: about 33% more, plus padding. 1,000 bytes become 1,336 characters with padding, and a 3 MB image becomes about 4 MB of Base64.
What is the difference between standard and URL-safe Base64?
URL-safe Base64 (RFC 4648 §5) uses - and _ instead of + and /, because those characters mean something in URLs and file names, and it is often written without = padding. JSON Web Tokens use it. For example, the bytes FB EF BE encode as ++++ in standard Base64 and as ---- in URL-safe Base64.
Why does my decoded text look garbled?
Usually because the Base64 holds binary data, such as an image, rather than text, or text in an encoding other than UTF-8. This decoder only shows text when the bytes are valid UTF-8; otherwise it shows the bytes in hex so you can see what they are.
Is Base64 a form of encryption?
No. Base64 is an encoding, not encryption: anyone can decode it instantly, with no key. Never use it to protect passwords or personal data. Use real encryption for secrets, and a password manager for passwords.