Base64 Encoder and Decoder Online: Encode, Decode, Convert (Free)
Encode text to Base64, decode Base64 to text, and convert files. 100% client side - no data leaves your browser.
Text ↔ Base64
Enter plain text on the left to encode, or paste Base64 on the right to decode. Supports full UTF-8.
File → Base64
Drag and drop a file or click to browse. The file will be converted to a Base64 string entirely in your browser.
Drag & drop a file here
or click to browse (max 10 MB)
Base64 → File Download
Paste a Base64 string (with or without a data URI prefix) and download it as a file.
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters. It is widely used across the web and in software development to safely transmit binary data over channels that only support text, such as email (MIME), HTML, CSS, and JSON.
How Base64 Works
Base64 encoding takes groups of three bytes (24 bits) and splits them into four 6-bit values. Each 6-bit value maps to one of 64 characters: A-Z, a-z, 0-9, +, and /. Padding with = is added when the input length is not a multiple of three. This makes the encoded output approximately 33% larger than the original binary data.
Common Use Cases for Base64
- Data URIs: Embed images, fonts, and other resources directly in HTML or CSS using
data:URIs. - API Payloads: Safely include binary data (images, PDFs, files) in JSON or XML API requests and responses.
- Email Attachments: MIME encoding uses Base64 to encode email attachments for transmission over SMTP.
- JWT Tokens: JSON Web Tokens use Base64url encoding (a URL safe variant) for the header and payload sections.
- Authentication: HTTP Basic Authentication encodes the username:password string in Base64.
- Storing Binary in Text Fields: Store small binary blobs in databases, config files, or environment variables that only accept text.
Base64 vs Base64url
Standard Base64 uses + and / characters, which are not URL safe. Base64url replaces these with - and _ respectively and typically omits padding. Base64url is used in JWTs and other URL-embedded data.
Is Base64 Encryption?
No. Base64 is an encoding scheme, not an encryption algorithm. Anyone can decode a Base64 string back to its original form. Never use Base64 to protect sensitive data. For encryption, use tools like SecureBin.ai's AES 256 encrypted paste.
Privacy & Security
This Base64 encoder/decoder runs entirely in your browser using JavaScript. No data is transmitted to any server. Your files and text never leave your device, making it safe for encoding sensitive content before sharing through secure channels.
How to Decode Base64 Images Online
If you have a Base64-encoded image string (starting with data:image/png;base64, or just the raw Base64), paste it in the decode field above. The tool will decode it back to binary and let you download the file. You can also use our Image to Base64 tool to convert images the other way.
Base64 in JavaScript: btoa() and atob()
JavaScript provides btoa() (encode) and atob() (decode) for Base64. However, btoa() only handles Latin-1 characters. For Unicode strings (emoji, CJK), use TextEncoder first:
// Encode Unicode-safe
btoa(String.fromCharCode(...new TextEncoder().encode("Hello 🌍")))
// Decode
new TextDecoder().decode(Uint8Array.from(atob(encoded), c => c.charCodeAt(0)))
Common Base64 Errors
- "InvalidCharacterError" from btoa(): Input contains non-Latin-1 characters. Use TextEncoder first.
- "Invalid character" when decoding: The string contains characters not in the Base64 alphabet. Check for accidental whitespace, line breaks, or URL-unsafe characters.
- Decoded output is garbled: The original data might be binary (image, PDF), not text. Save as a file instead of displaying as text.
- Base64 string is too long for URLs: Use Base64url encoding (replaces + with - and / with _) and remove padding. This is what JWTs use.
Related Tools
- Image to Base64 - convert images to data URIs
- URL Encoder/Decoder - encode special characters for URLs
- JWT Decoder - decode JWTs (which use Base64url)
- Hash Generator - SHA-256, MD5, and other hash functions
- Text Encryption - AES 256 encryption (not just encoding)
- Base64 Encoding Explained - deep dive into the algorithm
Frequently Asked Questions
How do I decode a Base64 image online?
Paste the Base64 string (with or without the data:image/... prefix) into the decode field and click Decode. If the output is binary, use the "Download as File" option to save it as an image file.
Is Base64 encoding the same as encryption?
No. Base64 is encoding, not encryption. Anyone can decode a Base64 string instantly. For encryption, use AES 256 encryption or create a zero knowledge encrypted paste.
Why is my Base64 output 33% larger?
Base64 converts every 3 bytes into 4 characters. This inherent 33% overhead is unavoidable. For large files, consider using multipart/form-data instead of Base64 encoding.
What is URL safe Base64?
URL safe Base64 replaces + with - and / with _, and typically removes = padding. It is used in JWTs, URL parameters, and filenames where standard Base64 characters have special meaning.