Base64 Encode / Decode
Encode text to Base64 or decode Base64 back to plain text. Supports URL-safe Base64 and binary data encoding. Encode text or binary data to Base64 format and decode Base64 strings back to original content for web development and data transmission.
Enter Values
Fill in the fields and press Calculate to see instant results.
Base64 Encoder & Decoder: Developer Utility Tool
Base64 encoding is one of the foundational utilities of the modern web. Whether you are embedding images directly into CSS via Data URIs, transmitting JSON Web Tokens (JWT) for authentication, or debugging an email MIME attachment, you need a reliable way to encode and decode Base64 strings. Our free Base64 Encoder/Decoder provides instant, client-side translation of text to and from Base64 format.
Because this tool runs entirely in your browser (client-side), your data is never sent to our servers. This ensures complete privacy and security when decoding API keys, authentication headers, or sensitive configuration strings.
⚠️ Critical Security Warning: Base64 is an encoding scheme, not an encryption scheme. It provides zero cryptographic security. Anyone with a browser can decode a Base64 string instantly. Never use Base64 to secure passwords or sensitive user data.
When to Use This Base64 Tool
🔐 Decoding JWTs (JSON Web Tokens)
JWTs are composed of three Base64-encoded strings separated by dots. Web developers frequently need to decode the payload section to inspect user claims, roles, and expiration times during debugging.
🖼️ Creating Data URIs for CSS
Encode small SVG icons or loading GIFs into Base64 to embed them directly in your CSS files, reducing HTTP requests and speeding up page rendering.
🔑 Basic Authentication Headers
The HTTP Basic Authentication protocol requires the credentials to be formatted as `username:password` and then Base64 encoded in the request header. Encode credentials to test API endpoints via Postman or cURL.
📧 Email & MIME Debugging
Email attachments (images, PDFs) are sent as massive blocks of Base64 text within the MIME structure. Developers use decoders to inspect corrupted email payloads.
🗄️ Database Storage Fixes
Some legacy databases struggle to store complex binary data or emojis correctly. Encoding data to Base64 (which is plain ASCII) ensures it can be stored safely in any standard VARCHAR column.
📜 Kubernetes Secrets
DevOps engineers use Base64 daily, as Kubernetes requires all Secret values (like database passwords and API keys) to be Base64 encoded in the YAML manifest files.
Base64 Encoding Formula & Algorithm
Base64 solves a very specific problem: How do you send binary data (like an image) across a network protocol (like early email) that was only designed to handle text?
The Base64 Alphabet
Base64 uses exactly 64 characters that are guaranteed to be safe and printable on any system:
Uppercase: A-Z (26 chars)
Lowercase: a-z (26 chars)
Numbers: 0-9 (10 chars)
Symbols: + and / (2 chars)
Total = 64 characters. (Plus the '=' sign used exclusively for padding)
The Mathematical Translation
1. The algorithm takes 3 bytes of original data (24 bits total).
2. It splits those 24 bits into 4 chunks of 6 bits.
3. Because 6 bits can represent 64 distinct values (2^6 = 64), each 6-bit chunk maps perfectly to one character in the 64-character alphabet.
4. Result: 3 bytes of raw data become 4 bytes of safe text data.
The 33% Bloat Rule: Because Base64 requires 4 characters to represent every 3 characters of original data, it increases the total file size by approximately 33%. This is why you shouldn't Base64 encode large video or audio files—the size penalty is too great.
Step-by-Step Guide to Base64
Verify Your Input
If you are decoding, ensure your string only contains valid characters (A-Z, a-z, 0-9, +, /, =). If it contains spaces, newlines, or other characters, the decoder may fail or produce garbage output.
Check for URL-Safe Base64
Standard Base64 uses + and /. These characters break URLs. "Base64url" encoding replaces + with - (dash) and / with _ (underscore). Most modern decoders handle both, but be aware of the difference.
Execute the Conversion
Click Encode or Decode. The browser instantly performs the bit-shifting logic locally.
Handle the Output
If encoding for HTTP Basic Auth, remember to prepend `Basic ` to your string. If using in CSS, prepend `data:image/png;base64,` to your string.
5 Worked Examples
Example 1: Basic Authentication Header
Requirement:
An API requires HTTP Basic Auth. You must encode the username and password combined with a colon.
Process:
- Input:
admin:supersecret123 - Action: Base64 Encode
- Output:
YWRtaW46c3VwZXJzZWNyZXQxMjM= - Final Header:
Authorization: Basic YWRtaW4...
Example 2: Decoding a JWT Payload
Requirement:
You need to know the User ID stored inside a JSON Web Token.
Process:
- JWT:
header.eyJ1c2VyX2lkIjoxMjM0NX0.signature - Extract middle payload:
eyJ1c2VyX2lkIjoxMjM0NX0 - Action: Base64 Decode
- Output:
{"user_id":12345}
Example 3: Understanding Padding (=)
Base64 requires inputs to be mapped in chunks of 3 bytes. Watch how the padding changes based on input length:
| Input | Bytes | Output (Encoded) | Padding |
|---|---|---|---|
| cat | 3 | Y2F0 | None (Perfect match) |
| ca | 2 | Y2E= | One Equal (=) |
| c | 1 | Yw== | Two Equals (==) |
Frequently Asked Questions
▶What is Base64 Encoding?
▶Is Base64 encoding the same as encryption?
▶Why do Base64 strings often end with equal signs (=)?
▶Does Base64 increase file size?
▶What is a Data URI?
▶How is Base64url different from standard Base64?
Related Developer Calculators
Explore our other tools designed for developers and IT professionals:
URL Encoder
Encode special characters into percent-encoding format (%20) to safely pass data in URL query strings.
Password Generator
Generate secure, cryptographically random passwords for your applications and databases.
Bandwidth Calculator
Calculate exact data transfer times for server migrations, taking network overhead into account.
Subnet Calculator
Calculate CIDR blocks, network ranges, and broadcast addresses for cloud infrastructure setups.
People Also Calculate
Calculators visitors commonly use alongside this one.