Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters. It was designed to safely transport binary data through systems that only handle text — such as email (MIME), HTTP headers, and XML. The name "Base64" comes from the 64 characters used in the encoding alphabet.
The encoding works by taking three bytes of input (24 bits) and splitting them into four 6-bit groups. Each 6-bit value maps to one character in the Base64 alphabet. If the input length is not a multiple of three, padding characters (=) are appended to reach a multiple of four output characters. The result is a string that is approximately 33% larger than the original data but safe to transmit as plain text.
Why Use This Tool?
This encoder handles Unicode text correctly, supports both standard and URL-safe variants, and encodes entirely in your browser — your data never leaves your machine.
⚡
Instant Encoding
Results appear as you type. No buttons to click, no waiting for a server response.
🔗
URL-safe Toggle
Switch between standard (+/) and URL-safe (-_) encoding with a single click. Padding is automatically removed for the URL-safe variant.
🔒
Fully Client-side
All encoding happens locally in your browser using the native btoa API and TextEncoder. Nothing is sent to any server.
🎛️
Unicode Support
Correctly handles full Unicode including emoji, CJK characters, and any UTF-8 text by using encodeURIComponent before encoding.
How to Use This Base64 Encoder Online
No account, no install, no upload — paste text and the encoded output appears instantly.
1
Paste or Type Your Text
Click the input field and paste any text — plain strings, JSON payloads, API keys, email addresses, or any UTF-8 content. Encoding updates live as you type.
2
Choose Your Variant
Select Standard (RFC 4648) for MIME, HTTP Basic Auth, and general use. Select URL-safe for JWT tokens, query string parameters, filenames, and any context where + or / would break URL parsing.
3
Copy the Output
Click Copy to send the Base64 string to your clipboard in one click. The output is ready to paste directly into your code, config file, or API request.
4
Use in Your Application
Paste the encoded string wherever needed — Authorization headers, data URIs, JSON fields, environment variables, or Kubernetes secrets. For URL-safe output, padding is already stripped.
The Base64 Alphabet
Base64 uses 64 characters: uppercase A–Z (values 0–25), lowercase a–z (26–51), digits 0–9 (52–61), and two special characters for values 62 and 63. The standard RFC 4648 variant uses + and /; the URL-safe variant replaces them with - and _ to avoid conflicts in URLs and filenames.
A–Z
0–25
ABCDEFGHIJKLMNOPQRSTUVWXYZ
a–z
26–51
abcdefghijklmnopqrstuvwxyz
0–9
52–61
0123456789
+, /
62–63
Standard RFC 4648 — avoid in URLs and filenames
-, _
62–63
URL-safe variant (RFC 4648 §5) — safe in URLs and filenames
Standard vs URL-safe Base64
The standard Base64 alphabet uses + and / which are special characters in URLs and file paths. The URL-safe variant replaces these with - and _ and typically omits padding = characters. Use URL-safe encoding for JWT tokens, data in query strings, filenames, and any context where + or / would be misinterpreted.
Input
Standard
URL-safe
Man
TWFu
TWFu
Hello
SGVsbG8=
SGVsbG8
A
QQ==
QQ
1+1=2
MSsxPTI=
MSsxPTI
Common Use Cases
Email Attachments (MIME)
SMTP was designed for 7-bit ASCII text. Base64 encoding is used by the MIME standard to safely embed binary attachments (images, PDFs, executables) in email messages.
Data URIs
Embed images, fonts, and other assets directly in HTML or CSS using data URIs: data:image/png;base64,... — eliminating extra HTTP requests for small resources.
API Payloads
REST APIs often require binary fields (file uploads, cryptographic keys, certificates) to be Base64-encoded when embedded in JSON, since JSON has no binary type.
Configuration Files
Kubernetes secrets, environment variables, and CI/CD configurations commonly store binary secrets and certificates as Base64 strings to avoid escaping issues.
HTTP Basic Auth
The HTTP Authorization: Basic header encodes credentials as Base64(username:password). This is not encryption — it only provides encoding for transport in headers.
JWT Tokens
JSON Web Tokens use URL-safe Base64 (base64url) to encode the header and payload segments, making the token safe to use in URLs and HTTP headers without escaping.
When NOT to Use Base64
Base64 is a transport encoding, not a security mechanism. These are the most common misuses that cause real problems in production:
✕
Not for Security or Encryption
Base64 is trivially reversible — no key or password is required to decode it. Anyone who sees a Base64 string can decode it in seconds. Never use Base64 as a substitute for encryption, hashing, or access control.
✕
Not for Compression
Base64 increases output size by ~33%. It is the opposite of compression. Do not use it to reduce payload size — use gzip, Brotli, or zstd instead.
✕
Not for Binary File Storage
Storing large binary files as Base64 in databases or JSON APIs wastes significant storage and memory. Use object storage (S3, R2, Cloudflare) and serve binary directly.
Code Examples
How to Base64-encode a string in popular languages and environments:
JavaScript (browser)
// Standard Base64
const encoded = btoa(unescape(encodeURIComponent(text)))
// URL-safe Base64 (no padding)
const urlSafe = btoa(unescape(encodeURIComponent(text)))
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')
Several Base64 encoders exist online. The key differentiators for daily developer use are privacy, correctness, and variant support.
Fully Private — No Server
This encoder runs entirely in your browser using the native btoa API and TextEncoder. Your text is never transmitted to any server — safe for API keys, tokens, and secrets.
Unicode-Correct Encoding
Many online Base64 tools silently corrupt non-ASCII input. This tool correctly handles full Unicode — emoji, CJK, Arabic, and all UTF-8 text — by encoding to UTF-8 bytes first.
Both Variants in One Place
Most tools only offer standard Base64. This encoder provides both standard (+/) and URL-safe (-_) variants with automatic padding handling — no manual character replacement needed.
Frequently Asked Questions
Is Base64 the same as encryption?
No. Base64 is an encoding scheme, not encryption. It is trivially reversible by anyone — no key or password is required to decode it. Never use Base64 to protect sensitive data. Use proper encryption (AES, RSA) for that purpose.
Why does Base64 output end with = or ==?
Base64 works in groups of 3 bytes (24 bits), producing 4 Base64 characters. If the input length is not a multiple of 3, padding characters (=) are appended to make the output length a multiple of 4. One = means the last group had 2 bytes; two = means it had 1 byte.
What is URL-safe Base64?
URL-safe Base64 (defined in RFC 4648 §5) replaces + with - and / with _ so the encoded string can be used in URLs, filenames, and HTTP headers without percent-encoding. It also typically omits the padding = characters.
How much does Base64 increase file size?
Base64 encoding increases size by approximately 33%. Every 3 bytes of input become 4 characters of output. For a 1 MB file, the Base64 output will be roughly 1.37 MB. This overhead is why Base64 is only used when necessary (e.g. embedding binary in text protocols).
Can I encode binary files with this tool?
This tool encodes text strings (which are then treated as UTF-8 bytes). To encode arbitrary binary files (images, PDFs, executables), use a language library or CLI tool that reads raw bytes, then feeds them to the Base64 encoder.
What is the difference between btoa() and Buffer.from().toString('base64')?
btoa() is a browser built-in that works on Latin-1 strings; it will throw for non-ASCII characters unless you encode to UTF-8 bytes first (using encodeURIComponent). Buffer.from(text).toString('base64') in Node.js handles UTF-8 strings directly and is the preferred approach on the server.
Does Base64 work with binary files?
This tool encodes text strings as UTF-8 bytes into Base64. For binary files (images, PDFs, executables), use a CLI tool or language library that reads raw bytes. In the browser, use FileReader.readAsDataURL() which returns a data URI with Base64-encoded binary content.
Is there a size limit for encoding?
This tool runs entirely in the browser with no server-side limit. Practical limits depend on your browser memory. For very large inputs (above a few MB), a CLI tool like base64 (Linux/macOS) or certutil -encode (Windows) is more efficient.