Base64 Encoder / Size Calculator
Calculate the encoded output size and overhead for Base64 encoding. Understand the math behind binary-to-text encoding used in email MIME, data URLs, and JSON.
Results
What is it?
Base64 is a binary-to-text encoding scheme that converts arbitrary binary data into a string of 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). It was designed to safely transport binary data through text-only channels like email (SMTP), HTTP headers, and JSON payloads. Every 3 bytes of input become exactly 4 ASCII characters of output โ always a fixed 33% size increase.
How to use
Enter the byte size of your input data. The calculator shows the exact encoded output length (always a multiple of 4 for padded Base64), the size overhead percentage (always approximately 33%), and the number of 76-character lines for MIME email encoding. To toggle between padded and unpadded output, select the appropriate Padding Style. Note: actual string encoding/decoding requires JavaScript btoa()/atob() or a server-side tool โ this calculator shows the sizing math.
Example scenario
A 1 MB (1,048,576 bytes) image embedded as Base64 in a data URL or JSON: encoded size = ceil(1,048,576 / 3) x 4 = 1,398,104 characters (approximately 1.33 MB). This 33% overhead is exactly why large images should be referenced by URL rather than inlined as Base64 in HTML, CSS, or API responses โ performance will suffer noticeably beyond a few KB.
Pro tip
In JavaScript: btoa(binaryString) encodes to Base64; atob(base64String) decodes. For arbitrary binary (images, PDFs): const b64 = btoa(String.fromCharCode(...new Uint8Array(arrayBuffer))). URL-safe Base64 replaces + with - and / with _ so the result is safe in URLs and filenames without percent-encoding. Node.js uses Buffer.from(data).toString("base64") and Buffer.from(b64, "base64"). Avoid inlining assets larger than ~10 KB as Base64; use external URLs instead for better caching and performance.