How to use the Base64 size calculator tool
- Type the size of your data in bytes into the Input bytes box, using digits only. Select Example to load 1024.
- Select Calculate to run the formula.
- Read the three lines in the Result box: the input, the padded Base64 length and the unpadded Base64URL length.
- Select Copy to paste the figures into a ticket, a code comment or a spreadsheet.
The formula behind the Base64 size calculator
Base64 packs 6 bits into each character, and a byte has 8. Three bytes are 24 bits, which is exactly four characters. Padded Base64 always writes whole groups of four, so its length is the byte count divided by three, rounded up, times four.
Unpadded output drops the = signs, so it needs only enough characters to cover the bits: the byte count times eight, divided by six, rounded up. One leftover byte takes two characters and two leftover bytes take three. The tool does this in whole-number arithmetic with no upper bound, so the answer is exact even for counts far beyond what floating-point math represents precisely.
padded = 4 * ceil(bytes / 3)
unpadded = ceil(bytes * 8 / 6)A worked example: 1024 bytes
1024 divided by 3 is 341 with one byte left over, so there are 342 groups and 1368 padded characters. The single leftover byte needs two characters and two = signs. Without padding the total is 1366. The two results differ by 0, 1 or 2 depending on the remainder.
- 1 byte: 4 characters padded, 2 unpadded.
- 2 bytes: 4 characters padded, 3 unpadded.
- 3 bytes: 4 characters either way.
- 1,000,000 bytes: 1,333,336 padded, 1,333,334 unpadded.
Input: 1024 bytes
Padded Base64: 1368 characters
Unpadded Base64URL: 1366 charactersWhat the result does not include
The figures cover the Base64 characters only. Add these yourself when they apply.
- Line breaks. MIME email wraps at 76 characters and ends each line with CRLF. 1368 characters fill 18 such lines and gain 36 bytes.
- A data URL prefix. The text data:image/png;base64, adds 22 characters.
- JSON overhead: two quotes plus the field name and punctuation.
- Storage width. Base64 is ASCII, one byte per character in UTF-8, but two bytes per character in UTF-16 strings and columns.
Input rules and planning with the numbers
The box accepts a non-negative whole number of bytes. Units, decimals, minus signs and thousands separators stop with Enter a non-negative whole byte count. Convert first: 1 MB is 1,000,000 bytes and 1 MiB is 1,048,576. Zero is allowed and gives zero.
To go the other way and find how much data fits under a character limit, divide the limit by four, round down and multiply by three. A field capped at 65,536 characters holds at most 49,152 bytes. The 20 MiB file limit of the encoders on this site corresponds to 27,962,028 characters.
Frequently asked questions
How do I calculate Base64 size from a file size?
Divide the size in bytes by three, round up, and multiply by four. That is the padded length in characters. Enter the byte count here to get the same figure without doing the arithmetic.
Why is Base64 about 33 percent larger than the input?
Each output character carries 6 bits while each input byte carries 8, a ratio of 4 to 3. Padding can add up to two more characters, which only matters for very small inputs.
What is the difference between the padded and unpadded numbers?
Padding fills the last group with = signs so the length is a multiple of four. Base64URL as used in tokens leaves them out. The gap is two characters when one byte is left over and one character when two are.
Can I enter kilobytes or megabytes?
No. The calculator reads digits only and treats them as bytes. Multiply first: use 1,000 per kilobyte or 1,024 per kibibyte, depending on which unit your limit is defined in.
How do I get the original size from a Base64 length?
Divide the padded length by four, multiply by three and subtract the number of = signs. A string of 1368 characters ending in two = signs holds 1024 bytes.