ONLINToolsPremium Suite

Base64 Encoder & Decoder

Encode text to Base64 or decode Base64 to text. Supports UTF-8 and file encoding. All processing happens locally in your browser.

Plain Text
0 chars
0 bytes
Base64 Output
0 chars
~% size

Complete Guide to Base64 Encoding

What is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data using 64 ASCII characters (A–Z, a–z, 0–9, +, /). It was designed to safely transmit binary data through text-only channels like email (MIME), URLs, and JSON. The name comes from using 64 different characters to represent data, with each character encoding 6 bits.

How Base64 Works

Base64 encoding takes every 3 bytes (24 bits) of input and converts them to 4 Base64 characters (6 bits each). This means Base64 output is always ~33% larger than the input. If the input length isn't divisible by 3, padding characters (=) are added.

Input: "Hi" → 01001000 01101001 (2 bytes = 16 bits)
Padded: 01001000 01101001 00000000 (3 bytes)
Base64: "SGk=" (S=18, G=6, k=36, = padding)

When to Use Base64

  • Data URIs: Embed small images directly in HTML/CSS (data:image/png;base64,...)
  • API payloads: Send binary data (files, images) in JSON requests
  • Email attachments: MIME encoding uses Base64 to transmit files through email
  • JWT tokens: The header and payload of JWTs are Base64URL encoded
  • Basic Auth: HTTP Basic Authentication encodes credentials as Base64

When NOT to use: Base64 is not encryption. It provides zero security — anyone can decode it. Never use Base64 to "hide" sensitive data like passwords or API keys.

FAQ

Why is Base64 output larger than the input?

Base64 converts 3 bytes → 4 characters, so output is always ~33% larger. For a 1 MB file, the Base64 version is ~1.37 MB.

What is Base64URL?

Base64URL replaces + with - and / with _ to make the output URL-safe. It's used in JWTs and anywhere Base64 appears in URLs.

Is my data sent to your server?

No. All encoding/decoding happens entirely in your browser using JavaScript's native btoa() and atob() functions. No data leaves your device.