Categories
Pages
<>

Base64 Encoder & Decoder

Encode any text or file to base64, or decode base64 strings back to readable text. Copy-ready

LIVE
392
Uses
1
Select typeChoose conversion direction
2
Enter amountType the value to convert
3
Get resultsSee live conversion rates
MODE
:

Copy the code below to embed this calculator on your website:

<iframe src="https://calculatorcafe.com/widget/base64-tool/" width="100%" height="500" frameborder="0" style="border:1px solid #e2e8f0;border-radius:12px"></iframe>

Free to use · Links back to CalculatorCafe

Base64 Encode and Decode in Your Browser

Paste plain text above and click encode to convert it into the Base64 alphabet (A-Z, a-z, 0-9, +, /) that every text-based system handles without corruption. Paste a Base64 string and click decode to restore the original content. This tool processes everything client-side using JavaScript's built-in atob() and btoa() functions - nothing is sent to a server, nothing is logged, and no account is required. Use it as a quick Base64 decoder when you encounter an encoded payload in an API response, email header, or JWT token, or as a Base64 encoder when you need to embed binary content into a JSON body, data URI, or configuration file.

How Base64 Encoding Works

The algorithm takes three bytes of input (24 bits) and splits them into four 6-bit groups. Each group maps to one of 64 printable characters. Three input bytes always produce four output characters, making the encoded result exactly 33% larger than the original. If the input length is not divisible by three, one or two = padding characters are appended. A 1 MB file becomes approximately 1.37 MB after base64 encoding. This overhead is the fundamental tradeoff for universal text-channel compatibility: email bodies, JSON payloads, XML documents, HTML attributes, and URL parameters can all safely carry Base64 content without corruption from control characters, null bytes, or encoding-sensitive delimiters.

Decode Base64 From APIs and Logs

REST APIs frequently return binary content (images, PDFs, compressed archives) as Base64-encoded strings inside JSON responses because JSON cannot represent raw bytes. Server logs, webhook payloads, and error reports often contain Base64-encoded request bodies or authentication tokens that need decoding to debug issues. To decode base64 from any source, paste the string above - the tool handles standard Base64 and the URL-safe Base64url variant (which replaces + with - and / with _) automatically. If the decoded output is binary (an image, a file) rather than readable text, the tool indicates the content type so you know what you are looking at.

Image to Base64 and Data URIs

Converting an image to base64 lets you embed it directly in HTML as a data URI: <img src="data:image/png;base64,iVBOR...">. This eliminates an HTTP request, improving initial render for small assets (icons, logos, sprites under 4 KB). CSS background-image declarations can use data URIs to bundle tiny graphics into the stylesheet itself. However, Base64 images cannot be cached independently from the containing document, and the 33% size increase means more total bytes transferred for larger files. For assets above 5-10 KB, separate image files with proper cache headers deliver better performance than inline base64 encoding.

Base64 in Authentication and Email

HTTP Basic Authentication transmits credentials as a Base64-encoded string in the Authorization header. This is encoding, not encryption - anyone who intercepts the header can decode it instantly. Base64 here merely ensures that usernames and passwords containing special characters survive HTTP header transport without corruption. Always pair Basic Auth with HTTPS. The MIME standard for email attachments also uses Base64: when you attach a PDF or image to an email, your client encodes the file into Base64 text, wraps it in MIME headers, and includes it in the message body. The receiving client reverses the process. MIME Base64 inserts line breaks every 76 characters per RFC 2045.

Base64 to Text, Image, PDF, and Hex

The decode operation restores whatever the original content was. If the source was plain text, you get readable text. If it was a PNG, you get PNG bytes (which the tool can display as a preview). Common conversions: base64 to text for decoding JWT payloads and API strings, base64 to image for extracting embedded graphics from JSON responses or CSS files, base64 to PDF for restoring encoded document attachments. For hexadecimal output, decode the Base64 first, then use a hex converter on the result - Base64 and hex are independent encoding layers that serve different purposes (Base64 is for text-safe transport, hex is for human-readable byte inspection).

Base64 in JavaScript and Python

In browser JavaScript, btoa() encodes a string to Base64 and atob() decodes it. For binary data (ArrayBuffers, Uint8Arrays), use the Buffer class in Node.js: Buffer.from(data).toString('base64') to encode and Buffer.from(b64, 'base64') to decode. In Python, the base64 module provides b64encode() and b64decode() functions that accept and return bytes objects. Both languages also support the URL-safe variant: JavaScript's btoa output with manual +/- and /_ replacement, or Python's base64.urlsafe_b64encode(). These built-in functions are what this tool uses under the hood, so the output matches exactly what your code would produce - useful for verifying expected encode/decode results during development and debugging.

Frequently asked questions

Is this tool free to use?
Yes, completely free with no registration, no ads tracking, and no usage limits.
Is my data kept private?
Yes. All processing happens in your browser. No data is sent to any external server.
Does it work on mobile devices?
Yes. Fully responsive design works on phones, tablets, and desktop computers.
Can I use the results commercially?
Yes. Output is yours to use for any personal or commercial purpose without restriction.
How accurate are the results?
Uses industry-standard algorithms tested across edge cases. Verify against known values for critical applications.
How do I report a bug or suggest a feature?
Use the feedback option on the page or contact us through the site. We actively maintain and improve all tools.
USER RATINGS

Rate This Calculator

Your feedback helps us improve our tools