Base64 Encoder / Decoder
Encode text and files to Base64 or decode Base64 strings instantly. Supports standard, URL-safe, and MIME encoding. Generate data URIs, preview images, drag & drop files. Free, real-time, 100% browser-based.
Text / File Input
0 chars
Base64 Output
0 B
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts any data — text, images, PDFs, or binary files — into a string of printable ASCII characters. It uses 64 characters (A-Z, a-z, 0-9, +, /) plus = for padding.
Every 3 bytes of input become 4 Base64 characters, making the output approximately 33% larger than the original. This trade-off allows binary data to travel safely through text-only channels like JSON, XML, email (MIME), and data URIs in HTML/CSS.
Common Use Cases
Embedding images in HTML/CSS — Convert small icons and logos to data URIs to eliminate extra HTTP requests and improve page load speed.
API data transmission — Send binary files (PDFs, images) through JSON APIs that only support text, or encode authentication tokens for HTTP headers.
Email attachments — MIME encoding is the standard for email attachments. Base64 ensures binary files survive transport through email servers.
Storing binary data in text formats — Save images or certificates in XML, JSON, or database text fields that don't support raw binary.
How to Use — 3 Simple Steps
Enter Your Input
Type or paste text to encode, or paste a Base64 string to decode. You can also upload or drag & drop any file — images, PDFs, documents — and the tool will encode it automatically.
Choose Mode & Options
Toggle between Encode and Decode. Select your encoding type: Standard, URL-safe, or MIME. Enable data URI prefix or line wrapping as needed.
Copy or Download
Results appear instantly as you type. Copy the output to clipboard, or download it as a file. For images, a preview is shown automatically.
Encoding Reference
| Input | Standard Base64 | URL-safe | Notes |
|---|---|---|---|
Hello | SGVsbG8= | SGVsbG8 | Padding removed in URL-safe |
A | QQ== | QQ | 2 padding chars for 1-byte input |
AB | QUI= | QUI | 1 padding char for 2-byte input |
ABC | QUJD | QUJD | No padding for 3-byte input |
Hello World! | SGVsbG8gV29ybGQh | SGVsbG8gV29ybGQh | Same when no +/ needed |
| (binary with +/) | a+b/c== | a-b_c | +/ become -_ in URL-safe |
Pro Tips
Small Images as Data URIs
For icons under 10 KB, data URIs eliminate an HTTP request. For larger images, use regular files — the 33% size increase outweighs the benefit.
URL-safe for Tokens
JWT tokens and API keys use URL-safe Base64 so they can appear in URLs without percent-encoding. Select “URL-safe” when working with tokens.
UTF-8 Support
This tool properly handles UTF-8 text (emoji, CJK characters, accents). Standard btoa() fails on non-ASCII — we encode UTF-8 first.
Decode with Whitespace
Pasting Base64 with line breaks? Enable “Strip whitespace on decode” to clean up before decoding. This handles MIME-formatted input automatically.
Frequently Asked Questions
What is Base64 encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into a sequence of printable ASCII characters. It uses 64 characters (A-Z, a-z, 0-9, +, /) to represent data, making it safe for transmission through text-based protocols like email, JSON, and URLs.
Why does Base64 make files larger?
Base64 encoding increases data size by approximately 33%. This is because it converts every 3 bytes of binary data into 4 ASCII characters. The trade-off is that the data becomes safely transmittable through text-only channels.
What is URL-safe Base64?
URL-safe Base64 replaces the standard + and / characters with - and _ respectively, and optionally removes padding (=). This makes the encoded string safe to use in URLs, query parameters, and filenames without additional encoding.
What is a Data URI?
A Data URI (data:mime/type;base64,...) embeds file data directly in HTML, CSS, or JavaScript as a Base64 string. This eliminates an extra HTTP request for small files like icons or logos, improving page load performance.
Is my data safe when using this tool?
Yes, completely safe. All encoding and decoding happens in your browser using JavaScript. Your data is never sent to any server. You can verify this by checking the Network tab in your browser developer tools.