54+ Local Tools Available
100% Browser Execution (No Uploads)
Zero Latency Instant Output
100% Private & Secure
Developer & Data Client Local

Base64 Encoder Decoder

A developer utility for converting text, JSON, images, and binary files between standard Base64 and URL-Safe Base64. Supports full UTF-8 multi-byte text, drag-and-drop file processing up to 50MB, padding (=) removal, Data URL formatting, and real-time image decoding previews — all processed locally in your browser memory.

Input
Load Sample Data:
0 chars0 bytesSize Change: -
Output Result
Base64 output will appear here...

Encoding & Formatting Options (Options)

Base64 Essentials

Size Overhead: Converting 8-bit binary into 6-bit ASCII characters increases data size by exactly 33.3% (4/3x).

Character Set: Uses 64 printable characters: A-Z (26), a-z (26), 0-9 (10), +, / (2), plus padding (=).

Not Encryption: Base64 is an encoding scheme for transport safety. Anyone can decode it without a key, so never use it as a security mechanism for passwords.

Input text, credentials, JSON payloads, and uploaded files are never transmitted to a cloud server. All processing stays inside your browser memory.

Data Encoding & Web Standards Specification

Mathematical Principles of Base64 Encoding & Modern Web Applications

Base64 is a binary-to-text encoding scheme that translates 8-bit binary data (images, PDFs, executables, compressed files) into a sequence of 64 printable ASCII characters, ensuring reliable transmission across text-based network protocols.

Legacy transmission systems (like early SMTP email servers) were designed for 7-bit ASCII and would corrupt binary bytes where the Most Significant Bit (MSB) was 1. Base64 solved this by re-encoding binary streams into safe, printable ASCII characters.

This guide examines 6-bit chunking mathematics, padding calculations, URL-Safe RFC 4648 standards, Data URL optimization techniques, multi-language code snippets, and security best practices.

Full UTF-8 Multi-Byte Character Support

Overcomes the Latin-1 limitation of standard JavaScript btoa() to encode Unicode and East Asian scripts without corruption.

Drag & Drop Large Binary File Handling

Extracts Base64 strings from images, PDFs, and ZIP archives up to 50MB instantly via the FileReader API.

URL-Safe & MIME 76-Character Line Wrapping

Generates output tailored to JWT authentication tokens, URL parameters, or PEM/MIME formatting standards.

Real-Time Decoded Media Preview & Export

Instantly view decoded Base64 images in an interactive canvas and download restored binary files with one click.

1. Mathematical Principles: 3 Bytes $\to$ 4 Characters Mapping

Bit Chunking Mechanism (8 bits×3=24 bits=6 bits×48\text{ bits} \times 3 = 24\text{ bits} = 6\text{ bits} \times 4):
- Standard bytes consist of 8 bits (28=2562^8 = 256 possible values).
- Base64 uses 64 characters (26=642^6 = 64), reading data in 6-bit increments.
- Every 3 consecutive bytes (24 bits) of binary data are split into four 6-bit integers and mapped to the Base64 index table (0A,1B,,63/0 \to A, 1 \to B, \dots, 63 \to /).
Padding Character (=) Rules:
- When total input bytes are not a multiple of 3, = padding characters are appended to maintain 4-character block alignment.
- 1 remaining byte (8 bits): Yields one 6-bit block + one 2-bit block (padded with 0000), followed by == to make 4 characters.
- 2 remaining bytes (16 bits): Yields two 6-bit blocks + one 4-bit block (padded with 00), followed by = to make 4 characters.
Size Expansion Formula (+33.3%):
- For an input of NN bytes, the resulting Base64 string length is:
- Base64 Length=4×N3=4N31.333N\text{Base64 Length} = 4 \times \left\lceil \frac{N}{3} \right\rceil = \frac{4N}{3} \approx 1.333 N

2. Binary-to-Text Radix Encoding Schemes Comparison Table

Comparison of common base encodings across character sets, overhead, and applications.

Encoding SchemeCharacter Set SizeCharacter Set CompositionSize OverheadPrimary Applications
Base64 (Standard)64 characters + =A-Z, a-z, 0-9, +, /+33.3% (4/3x)Email (MIME), Data URLs, file embedding, standard web APIs
Base64URL (RFC 4648)64 characters (no padding)A-Z, a-z, 0-9, -, _+33.3% (4/3x)JSON Web Tokens (JWT), URL query parameters, cookies
Base16 (HEX / Hexadecimal)16 characters0-9, a-f (or A-F)+100% (2x)Cryptographic hashes (SHA-256, MD5), memory dumps, color codes
Base32 (RFC 4648)32 characters + =A-Z, 2-7 (omits ambiguous chars)+60% (8/5x)OTP 2FA (Google Authenticator secrets), DNSSEC records
Base5858 charactersOmits 0, O, I, l to prevent confusion~+37%Bitcoin wallet addresses, IPFS content hashes, decentralization
Base85 (Ascii85)85 charactersPrintable ASCII glyphs+25% (5/4x)Adobe PostScript, PDF font/stream compression

3. Web Development Applications & Data URL Optimization

Data URLs (data:[<mediatype>][;base64],<data>) for Zero Network Requests:
- Inlining small icons or favicons (< 2KB) directly in HTML/CSS eliminates HTTP round-trips to accelerate First Contentful Paint (FCP).
- However, large assets (> 10KB) bloat document sizes and bypass browser caching, so external hosting in WebP/AVIF is preferred.
JSON Web Tokens (JWT) & Base64URL:
- JWT structures (Header.Payload.Signature) encode parts in Base64URL separated by dots (.).
- Replacing + with - and / with _ allows tokens to travel safely inside Authorization: Bearer <token> headers and URL parameters.
HTTP Basic Authentication Headers:
- Basic Auth encodes username:password in Base64 as Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=.

4. Security Notice: Base64 is NOT Encryption

Encoding vs. Encryption:
- Encoding: A public, reversible transformation standard designed for transport integrity; anyone can decode it without a secret key.
- Encryption (AES, RSA): Cryptographic obfuscation requiring private keys to decrypt.
Security Best Practice:
- Storing passwords, credit card numbers, or API keys in Base64 is equivalent to storing plain text. Always use strong symmetric/asymmetric encryption (AES-256-GCM) or one-way hashes (bcrypt, Argon2).

Developer Implementation Snippets for Base64 Encoding & Decoding

Production code examples across JavaScript/TypeScript, Python, Java, Go, PHP, C#, and CLI.

JavaScript / TypeScript (Web & Node.js)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// 1. Browser Environment (Full UTF-8 support)
function utf8ToBase64(str: string): string {
const bytes = new TextEncoder().encode(str);
const binString = Array.from(bytes, (byte) => String.fromCharCode(byte)).join('');
return btoa(binString);
}
 
function base64ToUtf8(base64: string): string {
const binString = atob(base64);
const bytes = Uint8Array.from(binString, (m) => m.charCodeAt(0));
return new TextDecoder().decode(bytes);
}
 
// 2. Node.js Buffer
const encoded = Buffer.from("Hello World", "utf-8").toString("base64");
const decoded = Buffer.from(encoded, "base64").toString("utf-8");
Python 3
1
2
3
4
5
6
7
8
9
10
11
12
13
import base64
 
# String encoding and decoding
text = "Hello World"
encoded_bytes = base64.b64encode(text.encode('utf-8'))
encoded_str = encoded_bytes.decode('utf-8')
print("Base64:", encoded_str)
 
decoded_str = base64.b64decode(encoded_str).decode('utf-8')
print("Decoded:", decoded_str)
 
# URL-Safe Base64
url_safe = base64.urlsafe_b64encode(text.encode('utf-8')).decode('utf-8')
Java (java.util.Base64)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import java.util.Base64;
import java.nio.charset.StandardCharsets;
 
public class Base64Example {
public static void main(String[] args) {
String text = "Hello World";
// 1. Standard Base64
String encoded = Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.UTF_8));
byte[] decodedBytes = Base64.getDecoder().decode(encoded);
String decoded = new String(decodedBytes, StandardCharsets.UTF_8);
// 2. URL-Safe Base64 (RFC 4648)
String urlSafe = Base64.getUrlEncoder().encodeToString(text.getBytes(StandardCharsets.UTF_8));
}
}
Go (Golang)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package main
 
import (
"encoding/base64"
"fmt"
)
 
func main() {
text := "Hello World"
// Standard Base64
encoded := base64.StdEncoding.EncodeToString([]byte(text))
fmt.Println("Encoded:", encoded)
decodedBytes, _ := base64.StdEncoding.DecodeString(encoded)
fmt.Println("Decoded:", string(decodedBytes))
// URL-Safe Base64
urlSafe := base64.URLEncoding.EncodeToString([]byte(text))
fmt.Println("URL-Safe:", urlSafe)
}
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
$text = "Hello World";
 
// Base64 Encode
$encoded = base64_encode($text);
echo "Encoded: " . $encoded . "
";
 
// Base64 Decode
$decoded = base64_decode($encoded);
echo "Decoded: " . $decoded . "
";
 
// URL-Safe Base64
$urlSafe = str_replace(['+', '/', '='], ['-', '_', ''], $encoded);
?>
C# / .NET
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
using System;
using System.Text;
 
class Program {
static void Main() {
string text = "Hello World";
// Base64 Encode
byte[] textBytes = Encoding.UTF8.GetBytes(text);
string encoded = Convert.ToBase64String(textBytes);
// Base64 Decode
byte[] decodedBytes = Convert.FromBase64String(encoded);
string decoded = Encoding.UTF8.GetString(decodedBytes);
}
}
Terminal / Bash CLI
1
2
3
4
5
6
7
# String encode and decode
echo -n "Hello World" | base64
echo "SGVsbG8gV29ybGQ=" | base64 -d
 
# File encode and decode
base64 -w 0 input.png > image_base64.txt
base64 -d image_base64.txt > output.png

DEVELOPER & DATA UTILITY FAQ

Q.How much does Base64 encoding increase file size?

Base64 increases file size by exactly 33.3% (4/3x) because 3 binary bytes (24 bits) are expanded into 4 ASCII characters (32 bits).

Q.What is the difference between standard Base64 and URL-Safe Base64?

Standard Base64 contains + and /, which can conflict with URL query delimiters. URL-Safe Base64 (RFC 4648) replaces + with - and / with _ and strips padding (=).

Q.What are the trailing equal signs (=, ==) at the end of a Base64 string?

Equal signs represent padding. When input bytes are not a multiple of 3, 1 (=) or 2 (==) padding characters are added to complete the final 4-character block.

Q.Why does JavaScript btoa() throw an error on non-English characters?

btoa() natively supports only 1-byte Latin-1 characters (0-255). This tool uses modern TextEncoder and Uint8Array to support all Unicode and Asian characters without error.

Q.Should I embed all website images as Base64 Data URLs?

Tiny icons (< 2KB) benefit from eliminated HTTP round-trips. Large images (> 10KB) should be hosted separately as WebP or SVG to leverage browser caching.

Q.Is Base64 secure for storing passwords or credit card numbers?

No. Base64 is an open encoding scheme that anyone can decode in seconds. Sensitive data must be encrypted with AES-256 or hashed with bcrypt/Argon2.

Q.How does the Decoded Image Preview feature work?

When decoding a Base64 image string (e.g. data:image/png;base64,...), the tool automatically renders a live image preview and provides a download button.

Q.Are my uploaded files or text sent to any remote server?

No. All Base64 conversions, file parsing, and image previews run locally in your browser memory.