Base64, Hex & URL Encoding Size Calculator

Calculate how much larger data becomes when encoded as Base64, Base64URL, hexadecimal or URL percent-encoding, and see the Base64 of your text.

Updated · Free · Runs in your browser

Measure
Base64 length —
Original size —
Base64URL (no padding) —
MIME Base64 —
Hexadecimal —
URL encoded —
Base64 output —
    Was this calculator helpful?

    The formula

    Base64 length = 4 × ⌈bytes ÷ 3⌉ (about 133% of the original)
    MIME Base64 adds a CRLF every 76 characters: + 2 × ⌊length ÷ 76⌋
    Base64URL without padding = ⌈4 × bytes ÷ 3⌉
    Hex length = 2 × bytes (200%)
    URL encoding: unreserved ASCII stays 1 character; every other byte becomes %XX (3 characters)

    Worked example

    1. "Hello, CalcLogs! 👋" is 21 bytes in UTF-8 (the emoji alone is 4 bytes).
    2. Base64 = 4 × ⌈21 ÷ 3⌉ = 28 characters: SGVsbG8sIENhbGNMb2dzISDwn5GL.
    3. Hex needs 42 characters, and URL encoding 35.
    4. A 2 MB image becomes about 2.67 MB as Base64, or 2.70 MB with MIME line breaks.

    Why encoding adds overhead

    Many systems were designed to carry text, not raw binary data: email, JSON, XML, URLs, HTML attributes and HTTP headers. To send images, files or encrypted data through them, the bytes have to be converted into safe printable characters. Each encoding scheme trades efficiency for compatibility. Base64 uses 64 characters, so each character carries 6 bits, and every 3 bytes (24 bits) become 4 characters, a 33% increase. Hexadecimal uses 16 characters carrying 4 bits each, so it doubles the size.

    Base64 variants

    Standard Base64 uses A–Z, a–z, 0–9, + and /, with = signs as padding to make the length a multiple of four. Email attachments use MIME Base64, which also breaks lines every 76 characters, adding about 2.6% more. Base64URL replaces + and / with - and _, which are safe in URLs and filenames, and usually drops the padding; it's used in JSON Web Tokens and many APIs. All variants have essentially the same size overhead. Our JWT decoder decodes Base64URL tokens.

    Data URIs and embedded images

    Embedding small images directly in HTML or CSS as Base64 data URIs saves an HTTP request, which can speed up pages with many tiny icons. But the image becomes 33% larger, can't be cached separately and delays the rendering of the HTML or CSS that contains it. As a rule of thumb, inline only very small images, under a few kilobytes, and serve larger ones as normal files. HTTP/2 and HTTP/3 make separate requests much cheaper, which reduces the benefit of inlining further.

    URL encoding

    URLs may only contain a limited set of characters. Letters, digits and - _ . ~ are left as they are, while spaces, punctuation and all non-ASCII characters are percent-encoded: each byte becomes a % sign followed by two hex digits. Because characters such as é and emoji take 2–4 bytes in UTF-8, each can become 6–12 characters in a URL. Browsers and servers often limit URLs to around 2,000–8,000 characters, so long encoded parameters belong in a POST body instead. For string lengths in bytes, see our UTF-8 string length calculator.

    Compression and transfer size

    Base64 text compresses reasonably well with gzip or Brotli, so when an encoded payload is sent over compressed HTTP, part of the overhead is recovered, though rarely all of it. Encrypted or already-compressed data, such as JPEG images and ZIP files, barely compresses, so the 33% overhead stays. If you control both ends, sending binary data directly, as multipart uploads, binary WebSocket frames or protocol buffers, is the most efficient option.

    Decoding Base64

    Decoding reverses the process: every 4 characters become 3 bytes, minus one byte for each = padding character. Invalid characters or a length that isn't a multiple of four (for padded Base64) indicate a corrupted or truncated string.

    Text encoding and bytes

    When you measure text, the calculator first converts it to UTF-8 bytes, the standard encoding on the web. ASCII characters take one byte each, most accented Latin, Greek and Cyrillic letters take two, most Chinese, Japanese and Korean characters take three, and emoji take four. The Base64 output shown is the standard encoding of those bytes, which you can copy for testing. For API and storage costs that depend on payload size, see the cloud cost calculator and data transfer time calculator.

    Frequently asked questions

    How much bigger is Base64?
    About 33% bigger: every 3 bytes become 4 characters. With padding, the length is always 4 × ⌈n ÷ 3⌉ characters.
    How do I calculate the Base64 size of a file?
    Divide the file size in bytes by 3, round up and multiply by 4. A 1 MB (1,000,000-byte) file becomes 1,333,336 characters.
    Why does Base64 end with = signs?
    Padding. When the input length isn't a multiple of 3, one or two = characters fill the final 4-character block.
    What is the difference between Base64 and Base64URL?
    Base64URL replaces + with - and / with _ so the result is safe in URLs and filenames, and often omits the = padding.
    Is Base64 encryption?
    No. Base64 is an encoding that anyone can reverse instantly. It offers no security; use proper encryption to protect data.

    ↑↓ to navigate · Enter to open