Base64 Guide: Encoding, Decoding, and Use Cases
Understand Base64 encoding for APIs, data URIs, and file transfer. Encode and decode locally with browser-based tools.
Base64 converts binary to text
Base64 encodes binary data as ASCII text using 64 printable characters. It appears in data URIs, email attachments (MIME), JWT payloads, API credentials, and anywhere binary data must travel through text-only channels.
Zovaty Base64 Tool
The Base64 tool encodes and decodes text and files locally in your browser. Paste text to encode, paste Base64 to decode. Nothing is uploaded to a server.
How Base64 encoding works
Base64 groups every 3 bytes (24 bits) into 4 characters (6 bits each). Padding with = characters handles input lengths not divisible by 3. The output is roughly 33% larger than the original binary data.
Common use cases
Data URIs: embed small images in CSS or HTML
JWT tokens: header and payload segments are Base64url encoded
API authentication: Basic auth credentials encoded in headers
Email attachments: MIME encoding for binary files
Storing binary in JSON or XML text fields
Base64 vs Base64url
Standard Base64 uses + and / characters, which conflict with URL syntax. Base64url replaces + with - and / with _. JWTs use Base64url. Standard Base64 appears in data URIs and MIME. Know which variant your system expects.
Base64 is not encryption
Base64 is encoding, not encryption. Anyone can decode it instantly. Never treat Base64-encoded credentials as secure. Use proper encryption (TLS, AES) for sensitive data in transit and at rest.
Conclusion
Base64 is a text-safe transport format, not security. Encode and decode instantly with the Base64 tool on Zovaty — local, free, and private.
Step-by-step encoding process
Base64 splits input into 3-byte groups (24 bits). Each group maps to 4 characters from the 64-character alphabet (A-Z, a-z, 0-9, +, /). Remainder bytes get padded with = characters. Decoding reverses this process.
Data URIs in web development
Data URIs embed small assets directly in HTML or CSS: img src="data:image/png;base64,...". Useful for tiny icons and critical CSS inlining. Avoid for large images — they bloat HTML and cannot be cached separately.
Debugging Base64 in APIs
API errors involving Base64 usually mean wrong padding, wrong alphabet (standard vs url-safe), or encoding text with wrong character set. Decode in the Base64 tool to inspect the actual content and identify the mismatch.
Base64 in email (MIME)
Email attachments are Base64 encoded within MIME multipart messages. The encoding adds 33% overhead to attachment size. Modern email systems handle this automatically, but understanding Base64 explains why email attachments are larger than the original files.
Storing binary data in text databases
Some systems store binary data as Base64 strings in text columns when binary column types are unavailable. This works but increases storage by 33% and requires encode/decode on every read. Prefer binary storage when your database supports it.
Base64 edge cases
Unicode text must be UTF-8 encoded before Base64 encoding. Newlines in encoded output may need stripping for URL embedding. Padding characters may need removal for URL-safe variants.
Encoding binary files
Small binary files (icons, certificates) can be Base64 encoded for embedding in config files or environment variables. Large files should remain as files — Base64 encoding increases size by 33%.
Base64 in API authentication
HTTP Basic Authentication encodes username:password as Base64 in the Authorization header. This is encoding, not encryption — always use HTTPS. For production APIs, prefer token-based auth over Basic Auth.
Debugging Base64 issues
Common failures: wrong padding, wrong alphabet (standard vs url-safe), UTF-8 not encoded before Base64, newlines in encoded string. Decode in the Base64 tool and inspect raw output to identify the issue.
Summary: Base64 essentials
Encoding not encryption. Use for text-safe binary transport. Decode to debug API issues. Encode/decode with Base64 tool locally.
Frequently asked questions
Is Base64 encryption?
No. Base64 is encoding — fully reversible by anyone. Use encryption for security.
Why is Base64 output larger than input?
Base64 uses 4 characters to represent 3 bytes — roughly 33% overhead.
What is the difference between Base64 and Base64url?
Base64url uses - and _ instead of + and / for URL-safe encoding. JWTs use Base64url.
Can I encode files in Base64?
Yes. The Zovaty Base64 tool handles text encoding. For large files, use command-line tools like base64 or openssl.
Why does Base64 end with = signs?
Padding characters ensure the encoded string length is a multiple of 4. They carry no data.
Related articles
JSON Formatter Guide: Validate, Beautify, and Debug
Format, validate, and minify JSON for APIs and configs. Common syntax errors, debugging workflow, and tools for developers.
4 min readBest Free Developer Tools for Daily Workflows
Essential free developer tools for JSON, Base64, UUID, regex, hashing, and JWT debugging. Browser-based utilities that run locally.
5 min readUUID Generator Guide: v4 vs v7 and When to Use Each
Generate UUIDs for databases, APIs, and distributed systems. Compare UUID v4 and v7, collision risk, and indexing best practices.
4 min read