Web & development / CLEARBYTE

Base64 encoded-size table with padding

Standard padded Base64 needs 4 × ceiling(original bytes ÷ 3) characters, excluding line breaks. Three input bytes become four encoded characters; very small inputs can have a larger percentage overhead because of padding.

Base64 encoded-size table with padding

Standard padded Base64 needs 4 × ceiling(original bytes ÷ 3) characters, excluding line breaks. Three input bytes become four encoded characters; very small inputs can have a larger percentage overhead because of padding.
Original bytesPadded Base64 charactersExtra characters vs input bytesSize increase
000Not applicable
143300.00%
242100.00%
34133.33%
1001363636.00%
1024136834433.59%
1000001333363333633.34%
1000000133333633333633.33%
Download this reference as CSV ↓

Formula & method

Encoded characters = 4 × ceil(n ÷ 3)
Increase% = (encoded characters ÷ n − 1) × 100 for positive n.

The formula assumes the standard padded Base64 representation, one-byte ASCII encoding, no line wrapping and no enclosing format. A JSON string adds quotes and possibly other structure. A data URL adds its media type and prefix. Percent-encoding the result can increase its size again.

Base64 is an encoding, not encryption or compression. A large binary payload approaches a four-to-three size ratio before any later transport compression. Unpadded Base64url can have a different length, so do not use the padded formula unchanged for that representation.

Worked example

A 1,024-byte binary payload becomes 1,368 Base64 characters: 4 × ceil(1,024 ÷ 3). The increase is 344 characters, approximately 33.59%, before adding a data-URL prefix or JSON wrapper.

What can change the answer

The table is for standard padded Base64 without line breaks. A smaller HTTP transfer after compression does not change the uncompressed encoded character count.

Sources & definitions

Method checked:

Continue with a related task