Base64 Encode/Decode
Encode text or files to Base64 and decode Base64 back instantly.
100% Private — Your files never leave your device.
All processing happens in your browser. Nothing is uploaded to any server.
How it works
What Is Base64?
Base64 is a group of binary-to-text encoding schemes that represent binary data as an ASCII string. The name comes from the 64 characters in its alphabet:
- 26 uppercase letters: A–Z
- 26 lowercase letters: a–z
- 10 digits: 0–9
- 2 symbols: + and /
- Padding character: =
How It Works
Base64 encoding takes every 3 bytes (24 bits) of input and splits them into 4 groups of 6 bits each. Each 6-bit group maps to one of the 64 characters. If the input length isn’t a multiple of 3, the output is padded with = characters.
Input: M a n
ASCII: 77 97 110
Binary: 01001101 01100001 01101110
6-bit: 010011 010110 000101 101110
Base64: T W F u
Common Use Cases
| Use Case | Why Base64? |
|---|---|
| Email attachments | SMTP only supports 7-bit ASCII. MIME encodes attachments as Base64. |
| Data URIs | Embed images directly in HTML/CSS without separate HTTP requests. |
| HTTP Basic Auth | Credentials are Base64-encoded in the Authorization header. |
| JSON/XML payloads | Safely include binary data in text-only formats. |
| API tokens | Many APIs encode token components as Base64 (e.g., JWT). |
Base64 vs Other Encodings
| Encoding | Alphabet Size | Overhead | Use Case |
|---|---|---|---|
| Base64 | 64 chars | ~33% | General binary-to-text |
| Base32 | 32 chars | ~60% | Case-insensitive contexts |
| Hex | 16 chars | 100% | Debugging, hash display |
| URL encoding | ASCII | Variable | URLs and query strings |
Privacy & Security
All encoding and decoding happens entirely in your browser. No data is sent to any server. This tool uses the Web Crypto API’s TextEncoder and native btoa/atob functions — the same primitives used by your browser internally.
Real-World Examples
Encoding API credentials for HTTP headers
A developer needs to send HTTP Basic Authentication credentials. The username:password pair is encoded to Base64 ('dXNlcm5hbWU6cGFzc3dvcmQxMjM=') and placed in the Authorization header as 'Basic dXNlcm5hbWU6cGFzc3dvcmQxMjM='. This is a standard requirement for REST APIs using Basic Auth.
Decoding a Base64-encoded email attachment
An email arrives with a Base64-encoded body (MIME encoding). Pasting the encoded string into the decoder instantly reveals the original text 'Hello World!'. MIME email encoding uses Base64 to safely transmit binary content through text-only email protocols.
Embedding a small image in CSS as a data URI
A web developer encodes a small PNG icon to Base64 to embed it directly in CSS as a data URI, eliminating an HTTP request. The 2KB PNG becomes approximately 2.7KB in Base64 (33% overhead), but saves a network round-trip. This technique is ideal for icons under 5KB.
Frequently Asked Questions
What is Base64 encoding?
Why is Base64 needed?
Is Base64 encryption?
What is the size overhead of Base64?
Does this tool handle Unicode and emoji?
What is the difference between Base64 and Base64URL?
Related Calculators
URL Encode/Decode
URL-encode and decode text instantly. Supports component and full URI modes.
JWT Decoder
Decode JWT tokens to inspect header, payload, and expiration.
JSON Formatter
Format, validate, and beautify JSON with syntax highlighting.
Password Generator
Generate strong, random passwords with customizable options.
CSV ↔ JSON Converter
Convert between CSV and JSON formats. Paste or upload, download instantly.