Base64 Encoder Decoder Calculator
Free Base64 encoder decoder Calculator for web & development. Enter parameters to get optimized results with detailed breakdowns.
Reviewed for accuracy by Daniel Agrici, Founder & Lead Developer
Base64 Encoder Decoder Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: Every 3 input bytes become 4 Base64 characters (6 bits each)
Worked example โ SGVsbG8sIFdvcmxkIQ== (18 chars from 13 input chars, 38% overhead)
Formula
Every 3 input bytes become 4 Base64 characters (6 bits each)
Base64 divides input bytes into 6-bit groups and maps each group to one of 64 printable ASCII characters. Input is padded to a multiple of 3 bytes, and output is padded with = signs to a multiple of 4 characters.
Worked Examples
Example 1: Encoding a Simple String
Problem:Encode 'Hello, World!' to Base64.
Solution:Convert each character to ASCII: H=72, e=101, l=108, l=108, o=111, ,=44, (space)=32, W=87, o=111, r=114, l=108, d=100, !=33 Group into 3-byte blocks and convert to 4 Base64 characters: Hel -> SGVs lo, -> bG8s Wo -> IFdv rld -> cmxk ! -> IQ== Result: SGVsbG8sIFdvcmxkIQ==
Result:SGVsbG8sIFdvcmxkIQ== (18 chars from 13 input chars, 38% overhead)
Example 2: Decoding a Base64 JWT Payload
Problem:Decode the Base64 string 'eyJuYW1lIjoiSm9obiJ9' (a JWT payload).
Solution:Base64 decode character by character: e=30, y=50, J=9, u=46, Y=24, W=22, 1=53, l=37... Group into 6-bit values, reconstruct bytes: Result bytes: 123 34 110 97 109 101 34 58 34 74 111 104 110 34 125 ASCII interpretation: {"name":"John"}
Result:eyJuYW1lIjoiSm9obiJ9 decodes to {"name":"John"}
Frequently Asked Questions
What is Base64 encoding and what is it used for?
Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters (A-Z, a-z, 0-9, +, and /). It is used whenever binary data needs to be transmitted through text-based channels that do not support raw binary. Common uses include embedding images in HTML/CSS using data URIs, encoding email attachments via MIME, transmitting binary data in JSON/XML, storing cryptographic keys and certificates in PEM format, and encoding authentication credentials in HTTP Basic Auth. Base64 ensures data integrity during transmission because all 64 characters are universally supported across different systems and protocols.
How does Base64 encoding work step by step?
Base64 encoding works by converting groups of three bytes (24 bits) into four Base64 characters (6 bits each). First, the input text is converted to its binary representation using ASCII/UTF-8 values. Then the binary stream is divided into 6-bit groups. Each 6-bit group (values 0-63) is mapped to one of 64 characters: A-Z (0-25), a-z (26-51), 0-9 (52-61), + (62), and / (63). If the input length is not a multiple of three, padding characters (=) are added to make the output length a multiple of four. For example, encoding 'Hi' (two bytes) produces 'SGk=' with one padding character.
Why does Base64 increase the data size by approximately 33 percent?
Base64 increases data size because it maps every 3 bytes of input to 4 bytes of output. The ratio is exactly 4/3, or approximately 33% overhead. This happens because each output character represents only 6 bits of data but occupies 8 bits (one byte) of storage. Three input bytes provide 24 bits of data, which requires exactly four 6-bit Base64 characters. Additionally, padding with equals signs can add 1-2 extra characters. For large data like images, this 33% increase can be significant. This is why Base64 is used for encoding, not compression. When transmitting large binary files, other methods like multipart/form-data are preferred over Base64 encoding.
What is the Base64 character set and why were these specific characters chosen?
The standard Base64 alphabet consists of 64 characters: uppercase A through Z (26 characters), lowercase a through z (26 characters), digits 0 through 9 (10 characters), plus sign (+), and forward slash (/). The equals sign (=) serves as padding. These characters were chosen because they are all printable ASCII characters that are safe to transmit through most text-based protocols. URL-safe Base64 variants replace + with hyphen (-) and / with underscore (_) because + and / have special meanings in URLs. Some implementations use different 62nd and 63rd characters for specific protocol requirements, but the core 62 alphanumeric characters are universal.
Is Base64 encoding the same as encryption?
No, Base64 is absolutely not encryption. Base64 is an encoding scheme that transforms data into a different representation without any security or secrecy. Anyone can decode Base64 data instantly without any key or password. It provides zero confidentiality. A common security mistake is Base64-encoding sensitive data like passwords and assuming they are protected. Base64 is as easy to reverse as converting uppercase to lowercase. For actual data protection, use proper encryption algorithms like AES-256 or RSA. Base64 encoding is often used alongside encryption, such as encoding encrypted binary output into text for transmission, but the Base64 step adds no security whatsoever.
How is Base64 used in web development with data URIs?
Data URIs allow embedding small files directly into HTML, CSS, or JavaScript using Base64 encoding. The format is data:[mediatype][;base64],data. For example, a small PNG image can be embedded as an img src attribute with the value data:image/png;base64, followed by the Base64-encoded image data. This eliminates an HTTP request, which can improve page load performance for small assets. CSS commonly uses data URIs for small icons and background images. However, Base64 data URIs increase the file size by 33% and cannot be cached independently, so they are best for files under 5-10 KB. Larger files should use traditional URL references for better performance.
What is the difference between Base64, Base32, and Base16 encoding?
These encodings differ in how many characters they use and their efficiency. Base64 uses 64 characters (6 bits per character), producing 4 output characters per 3 input bytes (33% overhead). Base32 uses 32 characters (5 bits per character), producing 8 output characters per 5 input bytes (60% overhead). It uses only uppercase letters and digits 2-7, making it case-insensitive and avoiding confusing characters. Base16 (hexadecimal) uses 16 characters (4 bits per character), producing 2 output characters per input byte (100% overhead). Base64 is most efficient for data encoding. Base32 is used in TOTP tokens and DNS names. Base16 is used for simple hex representations.
How does Base64 handle Unicode and non-ASCII characters?
Base64 itself operates on raw bytes and has no concept of character encoding. When encoding text containing Unicode characters, the text must first be converted to bytes using a specific encoding, typically UTF-8. A character like a copyright symbol (Unicode U+00A9) becomes two UTF-8 bytes (0xC2 0xA9) before Base64 encoding. Emoji and CJK characters may produce 3-4 UTF-8 bytes each. When decoding, the Base64 output bytes must be interpreted using the same encoding. This is why Base64 encoded strings of non-ASCII text may be longer than expected, as the UTF-8 encoding step may multiply the byte count before the 33% Base64 overhead.
What is URL-safe Base64 and when should I use it?
URL-safe Base64 (also called Base64url) replaces the standard characters + and / with - (hyphen) and _ (underscore) respectively, and typically omits padding equals signs. Standard Base64 characters + and / have special meanings in URLs (+ means space, / separates path segments), which causes problems when Base64 data appears in URLs or query parameters. URL-safe Base64 is specified in RFC 4648 and is used in JSON Web Tokens (JWT), OAuth tokens, and any context where Base64 data appears in URLs. Most programming languages have libraries supporting both variants. Always use URL-safe Base64 when the encoded data will appear in URLs, filenames, or HTTP headers.
How does Base64 encoding work with email attachments?
MIME (Multipurpose Internet Mail Extensions) uses Base64 to encode email attachments because the SMTP email protocol was originally designed to handle only 7-bit ASCII text. When you attach a file to an email, the email client encodes the binary file content using Base64, adds MIME headers specifying the content type and encoding method, and includes the encoded data in the email body. The receiving email client reads the headers, decodes the Base64 data back to binary, and saves or displays the attachment. Line length is typically limited to 76 characters in MIME Base64. Despite the 33% size increase, Base64 remains the standard email attachment encoding because it guarantees compatibility across all email servers and clients.
References
Background & Theory
History
Reviewed for accuracy by Daniel Agrici, Founder & Lead Developer ยท Editorial policy
Related Calculators
๐งฎBase64 Encode Decode Tool
Encode text to Base64 or decode Base64 strings back to plain text instantly.
๐งฎURL Encode Decode Tool
Encode special characters for URLs or decode percent-encoded URL strings.
๐งฎHtml Entity Encoder
Calculate html entity encoder with inputs, formulas, and instant results.
๐งฎBase64encode Decode Calculator
Calculate base64encode decode with inputs, formulas, and instant results.
๐งฎJwt Decoder
jwt decoder. Get instant, accurate results.
๐งฎBandwidth Time Transfer Calculator
Calculate bandwidth time transfer with inputs, formulas, and instant results.
๐งฎDownload Time Calculator
Calculate download time with inputs, formulas, and instant results.
๐งฎThroughput Efficiency Calculator
Calculate throughput efficiency with inputs, formulas, and instant results.