Base64 Encoder & Decoder
Encode text to Base64 or decode Base64 to text. Supports UTF-8 and URL-safe variants. Browser-side.
What is Base64?
Base64 is an encoding scheme that converts binary data into ASCII text. Created in the 1980s for the MIME email standard, it solved the problem of transmitting binary files through email systems that only supported 7-bit text. Base64 uses 64 printable characters (A-Z, a-z, 0-9, +, /) to represent any data, with = used for padding. The encoding makes data 33% larger than the original but ensures it survives transmission through text-only systems unchanged. Today Base64 is used everywhere: embedding images in HTML/CSS data URLs, JSON Web Tokens (JWT), email attachments (MIME), API request bodies, database storage of binary data, and authentication headers (HTTP Basic Auth uses Base64-encoded credentials).
How to use this tool
- Choose mode — Encode (text → Base64) or Decode (Base64 → text). Toggle tabs at the top.
- Enter input — Type or paste text/Base64 string. The tool processes instantly as you type.
- Optional: URL-safe encoding — Standard Base64 uses + and / which need URL encoding. URL-safe variant uses – and _ instead, and strips trailing = padding. Use this for URLs, JWT tokens, and other URL contexts.
- Copy or use output — Click ‘Copy output’ to put result on clipboard. Use ‘Use output as input’ to chain encode/decode operations (useful for testing or learning).
How Base64 encoding works
Base64 takes 3 bytes (24 bits) of input and converts to 4 ASCII characters (24 bits of useful data, since each char is 6 bits = 2^6 = 64 possible values).
- Take 3 input bytes
- Concatenate their binary representation (24 bits)
- Split into four 6-bit groups
- Map each 6-bit group (0-63) to a Base64 character
- If input length isn’t divisible by 3, pad with = signs
The 64 characters used:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
URL-safe variant replaces + with – and / with _, and removes trailing = padding for URL friendliness.
Size overhead: 4 chars per 3 input bytes = 33% expansion. So a 1 MB file becomes ~1.33 MB Base64-encoded.
Examples
- Encode ‘hello’ →
aGVsbG8=(5 bytes → 8 chars, 1 byte padding) - Encode ‘MavexTech’ →
TWF2ZXhUZWNo - URL-safe encoding of ‘a/b+c’ → standard:
YS9iK2M=, URL-safe:YS9iK2M(= stripped) - Decode ‘SGVsbG8gV29ybGQ=’ → ‘Hello World’
- JWT token format:
header.payload.signature– each part is URL-safe Base64 - HTTP Basic Auth header:
Authorization: Basic dXNlcjpwYXNz(where dXNlcjpwYXNz is Base64 of ‘user:pass’)
Tips & best practices
- Base64 is encoding (reversible), NOT encryption – never use it for security. Anyone can decode it instantly
- Use URL-safe variant when including Base64 in URLs, query strings, or JWT tokens – avoids URL encoding issues
- Don’t Base64-encode large files in HTTP requests if you can avoid it – 33% size overhead matters. Use multipart/form-data instead
- For embedding small images in HTML/CSS, Base64 data URIs eliminate HTTP requests (faster) – good for icons under 5 KB
- JSON Web Tokens (JWT) use URL-safe Base64 for header and payload – readable but not encrypted – never store sensitive data in JWT payload
- Email attachments are automatically Base64-encoded by your email client – you never see it but that’s why a 10 MB attachment makes a 13 MB email
- Save base64 data with a data URI prefix for direct browser use:
data:image/png;base64,iVBOR...
Limitations & notes
Base64 is encoding, not encryption – provides ZERO security. Adds 33% to data size, making it inefficient for large files. The output is case-sensitive – ‘A’ is different from ‘a’. Some systems strip whitespace incorrectly, breaking Base64. UTF-8 special characters are encoded as multi-byte sequences first, then Base64-encoded – normal here, but be aware when debugging.
Frequently Asked Questions
Is Base64 encryption?
No – Base64 is encoding, completely reversible by anyone. It’s like writing in cursive – looks different but anyone can read it. Use encryption (AES, RSA) for security; Base64 for transmitting binary as text. Common confusion – don’t make this mistake.
Why is Base64-encoded data larger?
Base64 uses 4 ASCII characters to represent 3 bytes of binary data – a 33% size increase. This is the tradeoff for text-safety. Modern systems support binary transmission so Base64 is often unnecessary – but it’s still standard for email, JWT, data URIs, and many APIs.
What’s the difference between standard and URL-safe Base64?
Standard uses + and / characters which require URL encoding (becoming %2B and %2F). URL-safe replaces these with – and _ respectively, and optionally strips trailing = padding. URL-safe is essential for use in URLs and query strings.
Can I Base64-encode a file?
Yes – read the file as binary, then encode the bytes. Common for HTML data URIs (embed images), API uploads, JWT payloads. JavaScript: FileReader.readAsDataURL() returns Base64 with mime prefix. Python: base64.b64encode(file.read()).
Why do some Base64 strings end with = or ==?
Padding to make total length a multiple of 4. If original data length is divisible by 3, no padding. If 1 byte extra, ends with ==. If 2 bytes extra, ends with =. Without padding, decoders can’t determine exact length. URL-safe variant typically omits padding.
Can I encode binary data like images?
Yes – upload a file or paste raw binary bytes. Result is the Base64 representation. For images specifically, use our ‘Image to Base64’ tool which handles file upload and provides ready-to-paste HTML/CSS data URIs.
What’s the maximum string length I can encode?
Browser memory is the limit – probably 100+ MB before slowdown. For very large files (>1 MB), prefer alternative encoding (multipart upload, binary transmission) since Base64’s 33% overhead becomes significant.
