Base64 Encode/Decode Online

Encode and decode text in Base64 quickly. Essential tool for developers working with APIs, images and binary data.

Supports UTF-8, emojis and accented characters

What is Base64?

Base64 is an encoding scheme that converts binary data into ASCII text using 64 printable characters (A-Z, a-z, 0-9, +, /). It is widely used to transmit binary data through media that only support text, such as email (MIME) and URLs.

How does Base64 encoding work?

Base64 encoding works by dividing the input into groups of 3 bytes (24 bits) and converting each group into 4 characters of 6 bits. When the number of bytes is not a multiple of 3, padding characters (=) are added at the end.

Conversion example:

Original text: "ABC"

Binary: 01000001 01000010 01000011

Grouped (6 bits): 010000 010100 001001 000011

Decimal: 16 20 9 3

Base64: "QUJD"

What is Base64 used for?

1. Embedding Images in HTML/CSS: Data URLs allow including images directly in code without additional HTTP requests.

<img src="data:image/png;base64,iVBORw0KGg..." />

2. Binary Data Transmission in JSON: REST APIs frequently use Base64 to send files or binary data in JSON payloads.

3. HTTP Basic Authentication: Credentials are Base64 encoded in the Authorization header.

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

4. Email (MIME): Email attachments are Base64 encoded to ensure compatibility with servers that only support 7-bit ASCII.

5. Temporary Storage: Store binary data in cookies, localStorage or sessionStorage.

Advantages and Disadvantages

✓ Advantages

  • Compatible with systems that only accept ASCII text
  • Easy to transmit via email, URL and JSON
  • Natively supported in all languages
  • Safe to copy/paste without data loss

✗ Disadvantages

  • Increases size by ~33% (overhead)
  • Not encryption (offers no security)
  • CPU cost for encode/decode
  • Not human-readable

Base64 vs Other Schemes

SchemeCharactersOverheadCommon Use
Base64A-Z, a-z, 0-9, +, /~33%Email, JSON, Data URLs
Base64URLA-Z, a-z, 0-9, -, _~33%URLs, JWT tokens
Hexadecimal0-9, A-F100%Hashes, CSS colors
Base32A-Z, 2-7~60%TOTP, backup codes

Practical use cases

🖼️ Data URL for favicon

Embed a favicon inline without external HTTP request:

🔑 HTTP Basic Auth

Send credentials in HTTP requests:

const credentials = btoa('username:password');
headers.Authorization = `Basic ${credentials}`;

📧 Email attachment

SMTP protocols use Base64 for attachments, ensuring that special characters don't corrupt the message during transmission.

Base64 is NOT encryption

⚠️ Important Warning

Base64 is an encoding scheme, not encryption. Anyone can decode Base64 instantly. Never use Base64 to protect passwords, tokens or sensitive data. For real security, use encryption algorithms like AES, RSA or bcrypt.

FAQ - Frequently Asked Questions

1. Why does Base64 increase file size?

Because it converts 3 bytes (24 bits) into 4 characters of 6 bits each. This generates an overhead of approximately 33%. A 1 MB file becomes ~1.33 MB in Base64.

2. What does the "=" at the end of Base64 strings mean?

The "=" sign is padding, added when the number of input bytes is not a multiple of 3. There can be 0, 1 or 2 "=" characters at the end.

3. Can Base64 be used for URLs?

Standard Base64 uses "+", "/" and "=" which are special characters in URLs. Use Base64URL (replaces + with -, / with _ and removes padding) for URL-safe encoding.

4. How to convert images to Base64?

In JavaScript: use FileReader API. Command line: base64 image.png. In Python: base64.b64encode().

5. Does Base64 support Unicode characters?

Yes! Our tool uses encodeURIComponent to support UTF-8, including emojis and accented characters.

6. What's the difference between btoa() and atob()?

btoa() = binary to ASCII (encodes). atob() = ASCII to binary (decodes). They are native JavaScript browser functions.

Related Tools