Was this tool helpful?
How to use the Base64 Encode / Decode
- 1Choose Encode or Decode.
- 2Paste text, or drop a file to get its Base64 data URI.
- 3Copy the result.
What is Base64?
Base64 represents binary data using 64 printable characters (A–Z, a–z, 0–9, + and /). It is used to embed images in HTML/CSS, send attachments in email, and put binary data inside JSON or URLs. Encoded data is about 33% larger than the original. URL-safe Base64 replaces + and / with - and _.
Where you'll see Base64
- Data URIs: small images embedded directly in HTML or CSS (data:image/png;base64,…).
- Email attachments: MIME encodes attachments as Base64.
- JSON Web Tokens (JWT): the header and payload are Base64URL-encoded, so anyone can decode and read them.
- HTTP Basic authentication sends username:password as Base64, which is why it must only be used over HTTPS.
Size overhead
Base64 turns every 3 bytes into 4 characters, so encoded data is about 33% larger than the original. That is fine for small icons and tokens but wasteful for large files. Base64URL replaces + and / with - and _ so the result is safe inside URLs.
How Base64 works, step by step
Base64 turns any bytes into 64 safe text characters (A–Z, a–z, 0–9, + and /). It takes 3 bytes (24 bits) at a time and writes them as 4 characters of 6 bits each. Take "Hi!": the bytes 72, 105 and 33 become the bits 010010 000110 100100 100001, which are characters 18, 6, 36 and 33 of the alphabet: SGkh.
When the input isn't a multiple of 3 bytes, the output is padded with = signs, which is why "Hello" encodes to SGVsbG8=. Text is converted to UTF-8 first, so accented letters and emoji work: "é" is two bytes and encodes to w6k=.
Base64 makes data about a third bigger
Every 3 bytes become 4 characters, so encoded data is about 33% larger than the original:
| Original | Base64 length |
|---|---|
| 3 bytes | 4 characters |
| 1 KB (1,024 bytes) | 1,368 characters |
| 100 KB | 136,536 characters |
| 1 MB | 1,398,104 characters |
URL-safe Base64 and data URLs
Standard Base64 uses + and /, which have special meanings in web addresses. The URL-safe option swaps them for - and _ and drops the = padding, the form used in JWT tokens and many APIs. When decoding, the tool accepts both forms and strips a data:…;base64, prefix automatically.
Frequently asked questions
Is Base64 encryption?
No. Base64 is an encoding, not encryption: anyone can decode it. Never use it to protect secrets.
Is my data sent anywhere?
No. Encoding and decoding happen in your browser.
Is Base64 encryption?
No. Base64 is an encoding that anyone can reverse instantly. Never use it to hide passwords or secrets; use real encryption instead.
Why does my decoded text look garbled?
The data was probably not text (for example an image or a compressed file), or it was encoded from a character set other than UTF-8. Decode files with the file option instead.