Base64 Converter
Convert units with the Base64 Converter — enter a value and get accurate converted results instantly using verified formulas.
Formula
Base64: 3 bytes → 4 characters (33% size increase)
Base64 takes 3 bytes (24 bits) and divides them into 4 groups of 6 bits. Each 6-bit value (0-63) maps to a character from the 64-character alphabet. Padding with '=' is added when input length isn't divisible by 3.
Worked Examples
Example 1: Encode Credentials for API
Problem:Create Basic Auth header: username 'admin' and password 'secret123'.
Solution:Combine with colon: admin:secret123 Base64 encode: Input: admin:secret123 Output: YWRtaW46c2VjcmV0MTIz HTTP Header: Authorization: Basic YWRtaW46c2VjcmV0MTIz Note: This is encoding, NOT encryption. Use HTTPS for security!
Result:YWRtaW46c2VjcmV0MTIz
Example 2: Create Data URL for Small Image
Problem:Embed a tiny 1x1 transparent PNG directly in CSS.
Solution:1x1 transparent PNG Base64: iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII= CSS usage: .element { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='); }
Result:Data URL ready for CSS
Example 3: Decode Unknown Base64
Problem:Received Base64 string: SGVsbG8gV29ybGQh — what does it say?
Solution:Input (Base64): SGVsbG8gV29ybGQh Click 'Decode from Base64' Output: Hello World! Analysis: - 18 input characters - Decodes to 12 characters - Standard ASCII text - No padding needed (divisible by 4)
Result:Hello World!
Frequently Asked Questions
What is Base64 encoding and how does it work?
Base64 is a binary-to-text encoding scheme that converts binary data into ASCII text using 64 printable characters: A-Z (26), a-z (26), 0-9 (10), + and / (2). It works by taking 3 bytes (24 bits) of binary data and splitting them into 4 groups of 6 bits each. Each 6-bit group (values 0-63) maps to one of the 64 characters. This makes binary data safe for text-based systems.
Why does Base64 make data larger?
Base64 increases size by approximately 33%. Every 3 bytes of input becomes 4 characters of output because you're representing 8-bit bytes with 6-bit characters. Additionally, padding ('=' characters) is added when input length isn't divisible by 3. A 1MB file becomes ~1.37MB when Base64 encoded.
When should I use Base64 encoding?
Use Base64 for: embedding images in HTML/CSS (data URLs), including binary data in JSON, sending attachments via email (MIME), storing binary in text-only databases, encoding credentials in HTTP Basic Auth, and transmitting data through text-only protocols. Don't use it for encryption—it's encoding, not security.
What is the difference between Base64 and encryption?
Base64 is encoding—it transforms data format but provides NO security. Anyone can decode Base64 instantly. Encryption scrambles data using a key, making it unreadable without the key. Never use Base64 to 'hide' sensitive data; use proper encryption (AES, RSA) for security. Base64 is for compatibility, not confidentiality.
What are Base64 URL-safe variants?
Standard Base64 uses + and / which have special meanings in URLs. URL-safe Base64 (Base64URL) replaces + with - and / with _ to avoid URL encoding issues. Some variants also omit padding (=). Use URL-safe Base64 for: query parameters, file names, JWT tokens, and anywhere URL encoding would cause problems.
Why do I get errors when decoding Base64?
Common decode errors: 1) Invalid characters (not in Base64 alphabet), 2) Incorrect padding (wrong number of = signs), 3) Truncated data (incomplete encoding), 4) Wrong variant (URL-safe vs standard), 5) Extra whitespace or line breaks. Our tool shows specific error messages to help diagnose issues.
How do I encode images as Base64?
Convert image to Base64 for use in data URLs: 1) Read image as binary, 2) Base64 encode the binary, 3) Create data URL: 'data:image/png;base64,<encoded-data>'. This embeds the image directly in HTML/CSS, reducing HTTP requests but increasing page size. Best for small images (icons, thumbnails) under 10KB.
What is MIME and how does it relate to Base64?
MIME (Multipurpose Internet Mail Extensions) uses Base64 to encode email attachments. Email was designed for text only, so binary attachments must be encoded. MIME Base64 typically includes line breaks every 76 characters for compatibility with older email systems. Our tool produces continuous Base64 suitable for web applications.
Can I encode non-English text with Base64?
Yes, but the text must first be encoded to bytes (usually UTF-8). JavaScript's btoa() only handles Latin-1 characters directly. For Unicode text, first encode to UTF-8 bytes, then Base64 encode those bytes. When decoding, reverse the process: Base64 decode, then interpret as UTF-8. Our tool handles standard ASCII text.
What are alternatives to Base64?
Alternatives include: Base32 (uses 32 characters, case-insensitive, 60% larger), Base16/Hex (uses 0-9, A-F, 100% larger but very simple), Base85/Ascii85 (uses 85 chars, only 25% larger, used in PDF/PostScript), and Base62 (alphanumeric only, no special chars). Choose based on allowed character set and size requirements.