Base64 Overhead Calculator
Base64 encoding converts binary data into a printable text format using 64 ASCII characters, making it safe for transmission in contexts that only support text (such as email, URLs, and JSON). The cost is a 33% size increase: every 3 bytes of binary data become 4 characters. This calculator takes an input size in bytes and returns the exact Base64 encoded size in characters (with padding), the overhead in bytes and percentage, and the equivalent without padding (Base64url without =). These figures help developers plan API response sizes, JWT token lengths, and storage requirements for encoded binary data.
Base64 encoding formula
Encoded size (with padding) = ceil(n / 3) × 4
Overhead bytes = encoded size - n
Overhead % = (encoded size - n) / n × 100
Without padding = ceil(n / 3) × 4 - ((3 - n mod 3) mod 3)
For n = 1,000 bytes: ceil(1000/3) = 334, so encoded size = 334 x 4 = 1,336 characters. Overhead = 336 bytes (33.60%). This matches the theoretical 33.33% overhead for large inputs; padding adds slight variability for small inputs.
Base64 use cases in security and cryptography
- PEM certificates: X.509 certificates encoded as Base64 between BEGIN/END headers.
- JSON Web Tokens (JWT): header, payload, and signature each Base64url-encoded.
- SAML assertions: XML security tokens Base64-encoded for HTTP POST binding.
- HTTP Basic Auth: username:password encoded in Base64 in the Authorization header.
- SSH public keys: RSA/Ed25519 keys stored as Base64 in authorized_keys files.
Base64 overhead calculator: frequently asked questions
How does Base64 encoding work?
Base64 encodes binary data using only 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). Every 3 bytes (24 bits) of input are split into four 6-bit groups, each mapped to one of 64 characters. If the input length is not a multiple of 3, padding characters (=) are added.
Why does Base64 add overhead?
Base64 uses 6 bits per character instead of 8 bits, so 3 bytes (24 bits) of binary data require 4 characters (24 bits at 6 bits each). This is a 33% increase in size. Base64 output is also padded to the nearest multiple of 4 characters.
What is the formula for Base64 output size?
Base64 encoded size = ceil(input bytes / 3) x 4. For example, 100 bytes encodes to ceil(100/3) x 4 = 34 x 4 = 136 characters, an overhead of 36 bytes (36%).
What is Base64url and how does its size differ?
Base64url replaces + with - and / with _ to make the encoding safe for URLs and filenames. The encoded size is identical to standard Base64. Base64url without padding omits the trailing = characters, slightly reducing the size for some inputs.
Where is Base64 encoding commonly used in security?
Base64 is widely used to encode binary cryptographic data as text: certificates (PEM format), JSON Web Tokens (JWT), SAML assertions, HTTP Basic Authentication credentials, and embedding binary data in HTML or JSON. It is an encoding scheme, not encryption, and provides no security itself.
Official sources
- IETF RFC 4648 The Base16, Base32, and Base64 Data Encodings: rfc-editor.org/rfc/rfc4648.
- IETF RFC 7515 JSON Web Signature (uses Base64url encoding): rfc-editor.org/rfc/rfc7515.
Reviewed by the CalculatorHub team, edited by James Graham, 15 June 2026. See our methodology.