Base64 encode/decode: text, files, images, binary. URL-safe Base64, decode to text/hex. Online Base64 converter with file upload support.
Use this free online Base64 / Base32 / Base58 / Base85 Encoder directly in your browser. No signup required, no data leaves your device. Part of Utilier — a collection of 133+ developer utilities.
What is Base64 Encoder/Decoder (Text, File, Image, URL-Safe)?
Base64 encoder converts binary data to ASCII text using 64 printable characters (A-Z, a-z, 0-9, +, /). Used for: embedding images in HTML/CSS (data URLs), email attachments (MIME), API authentication (Basic Auth), storing binary in JSON/XML (text-only formats). Encoding: 3 bytes → 4 ASCII characters (33% size increase). Decoding: reverses process (Base64 text → original binary). Features: text encoding (UTF-8 → Base64), file encoding (upload → Base64 string), image encoding (→ data URL), URL-safe variant (+ → -, / → _, no padding =), decode to text/hex/binary. Use cases: data URLs (embed images in CSS), JWT tokens (header.payload.signature), API keys (binary → transmittable string), email attachments (binary → 7-bit ASCII).
Text to Base64: UTF-8 text → Base64 ASCII. Example: 'Hello' → 'SGVsbG8=' (6 chars → 8 Base64 chars). Reversible: 'SGVsbG8=' → 'Hello'. Use: transmit text safely (no special chars), store in JSON.
File/Image encoding: Binary file → Base64 string. Image upload → data URL: data:image/png;base64,iVBORw0KG... (embeddable in HTML <img src='data:...'> or CSS background). Large files = very long strings (33% larger).
Decoding: Base64 string → original data. Text: 'SGVsbG8=' → 'Hello' (UTF-8). Binary: decode to hex (00 48 65 6C 6C 6F) or file download. Validates: invalid chars → error.
Padding (=): Base64 output length must be multiple of 4. Padding = added if needed. Example: 'Hello' → 'SGVsbG8=' (1 padding char), 'Hi' → 'SGk=' (1 =), 'H' → 'SA==' (2 =). Decoding: padding removed/optional.
Why use base64?
Transmit binary data over text-only channels (email, JSON, URLs). Embed resources in code.
Embed images in HTML/CSS: Data URL: <img src='data:image/png;base64,iVBORw...'> (no separate image file request). CSS: background-image: url(data:...). Reduces HTTP requests (faster load), but larger HTML (33% overhead).
Email attachments (MIME): Email (SMTP) = 7-bit ASCII only. Binary attachments → Base64 (8-bit → 7-bit). Example: PDF attachment encoded in MIME multipart. Recipient: decodes to original binary.
JSON/XML binary data: JSON/XML = text formats (no binary). Store binary: encode as Base64 string. Example: {"file": "SGVsbG8="} (binary data as text). API responses: images, PDFs as Base64.
API authentication: HTTP Basic Auth: username:password → Base64 → Authorization: Basic dXNlcjpwYXNz. Not encryption (easily decoded), just encoding for transmission. Use with HTTPS (secure channel).
Binary in URLs: URL parameters = text only. Binary ID → Base64 (URL-safe): id=a-b_c (- and _ safe, no + or /). Or filenames: image-a_b.png (no special chars).
When to use base64
Use when encoding binary for text transmission or embedding resources.
Embedding images in HTML/CSS (data URLs, inline images).
Storing binary data in JSON/XML (API responses, config files).
Email attachments (MIME encoding for SMTP transmission).
API authentication (Basic Auth header encoding).
JWT tokens (header and payload encoding).
Binary data in URLs (URL-safe encoding for query params).
Encoding files for upload (binary → text for form submission).
QR codes (data URLs for inline QR images).
How to use base64
Enter text or upload file, encode to Base64, or decode Base64 to original.
Encode text: Input text: 'Hello World'. Select: Encode. Output: 'SGVsbG8gV29ybGQ=' (Base64 string). UTF-8 text → Base64 ASCII. Copy result for use in JSON, APIs.
Encode file/image: Upload file (image, PDF, binary). Tool reads file → Base64 string. Image: outputs data URL (data:image/png;base64,...). Copy data URL → paste in <img src='...'> or CSS.
Decode to multiple formats: Base64 input → decode to: text (UTF-8), hex (48 65 6C 6C 6F), binary (file download). Auto-detect: text vs binary. Invalid UTF-8 → show hex/binary only.
Inline images (data URLs): Small logo: upload → data URL: data:image/png;base64,iVBORw... Use in HTML: <img src='data:...'> (no external file). Reduces HTTP requests (1 less request). Trade-off: larger HTML (33% overhead).
API image upload: POST /api/upload with JSON: {"image": "iVBORw0KG..."} (Base64-encoded image). Server decodes → saves file. Alternative to multipart/form-data. Simpler for JSON APIs.
Email attachment: SMTP email with PDF attachment. Encode PDF → Base64. MIME: Content-Transfer-Encoding: base64. Body: Base64-encoded PDF. Receiver decodes → original PDF.
MIME Base64 (email): max 76 chars per line, CRLF breaks. RFC 2045. Example: long Base64 split into multiple lines. Decoder: ignores line breaks (strips before decoding). Tool: no line breaks (single string).
Invalid characters
Only A-Z, a-z, 0-9, +, /, = valid. Others: error. Whitespace (space, tab, newline): ignored or error (depends on decoder). Tool: strict (no whitespace in output, optional in input).
Binary vs text
Base64 works on bytes (binary). Text: UTF-8 → bytes → Base64. Binary: raw bytes → Base64. Decode: bytes → interpret as UTF-8 (text) or raw (binary). Invalid UTF-8: show hex/binary.
Base64 is encoding, NOT encryption. Easily decoded (no secret key). Example: Basic Auth 'dXNlcjpwYXNz' → 'user:pass' (plaintext). Always use HTTPS for sensitive data. Base64 = obfuscation, not security.
Common mistakes to avoid
Using Base64 for encryption (it's encoding, not secure)
Why it happens: Base64 easily decoded (no key needed). Example: 'dXNlcjpwYXNz' → 'user:pass' (anyone can decode). Not secure (visible to attackers).
How to avoid it: Use encryption (AES, RSA) for security. Base64 = encoding for transmission (not hiding data). Always HTTPS for sensitive data (encrypts channel, not just Base64).
Not using URL-safe Base64 for URLs/filenames
Why it happens: Standard Base64: + and / invalid in URLs (need %2B, %2F escaping). Filename: / is path separator (breaks paths). Example: token=a+b/c → a%2Bb%2Fc (ugly, longer).
How to avoid it: Use URL-safe Base64: + → -, / → _. Example: a-b_c (no escaping needed). Set option in tool or use URL-safe encoding function.
Large data URLs (slow page load)
Why it happens: Image 500 KB → Base64 665 KB → data URL in HTML. Entire HTML + Base64 = large (slow download). Browser: can't cache data URL (re-downloaded with HTML every time).
How to avoid it: Use data URLs for small images only (<10 KB: icons, logos). Large images: external files (browser caches, parallel downloads). Data URL = convenience vs performance trade-off.
Incorrect padding (length not multiple of 4)
Why it happens: Base64 output must be multiple of 4 chars. Example: 'SGVsbG8' (7 chars, missing 1 =) → invalid. Decoder error: incorrect padding. Some decoders lenient (add padding), others strict (error).
How to avoid it: Use tool (auto-adds padding). Manual: add = until length % 4 == 0. Example: 'SGVsbG8' → 'SGVsbG8=' (8 chars). Check output before using.
How to avoid it: Always UTF-8 for text. Tool: defaults to UTF-8 (ensure option set). Decode: same encoding as encode. Mismatch → garbled text.
Frequently asked questions
What is the difference between Base64 encoding and encryption?
Base64 = encoding (reversible without key, anyone can decode). Encryption = requires secret key to decrypt. Base64: 'SGVsbG8=' → 'Hello' (easy). Encryption: ciphertext → plaintext (only with key). Use Base64 for transmission, encryption for security.
Why is Base64-encoded data larger than the original?
3 bytes → 4 Base64 chars (4/3 = 1.33, 33% larger). Example: 300 KB → 400 KB Base64. Trade-off: size for text compatibility (binary → ASCII, safe for email/JSON).
What is URL-safe Base64?
Standard: +, /, = chars (not URL-safe). URL-safe: + → -, / → _, = removed. Use in URLs, filenames (no escaping). Example: 'a+b/c=' → 'a-b_c' (safe in URL query params).
Can I encode any file type to Base64?
Yes. Base64 works on bytes (binary). Any file (image, PDF, video, ZIP) → Base64 string. Decode: Base64 → original binary file. Large files → very long Base64 strings (consider size).
What is a data URL?
data:[<mediatype>][;base64],<data>. Example: data:image/png;base64,iVBORw... Embeds resource in URL (no external file). Use in HTML <img src='data:...'>, CSS background. Inline resources (no HTTP request).
Why does Base64 have padding (=)?
Output must be multiple of 4 chars (encoding 3-byte groups). Not multiple? Add = padding. Example: 'A' (1 byte) → 'QQ==' (2 =), 'AB' → 'QUI=' (1 =), 'ABC' → 'QUJD' (no =). Decoder: uses padding to determine original byte count.
Is Base64 case-sensitive?
Yes. A-Z and a-z are different characters (52 total). Example: 'A' (index 0) ≠ 'a' (index 26). Changing case: 'SGVsbG8=' ≠ 'sgvsbg8=' (different data). Must match exactly when decoding.