Base64 Encoder/Decoder
Encode text to Base64 or decode Base64 strings back to plain text. Fast, secure, and works offline in your browser.
Base64 Usage Tips
- Base64 encoding increases data size by approximately 33%
- Use Base64 to encode binary data for text-based protocols
- URL-safe encoding replaces + and / with - and _ for safe URLs
- Base64 is encoding, not encryption - don't use for security
- Perfect for embedding images in CSS or HTML (data URLs)
- Commonly used in email attachments and API responses
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It's designed to carry data stored in binary formats across channels that only reliably support text content. Base64 uses 64 different ASCII characters (A-Z, a-z, 0-9, +, /) to represent binary data.
The encoding process converts groups of three bytes (24 bits) into four Base64 characters. This makes the data approximately 33% larger but ensures it can be safely transmitted through text-based protocols like email, JSON, XML, or URLs without corruption.
How Base64 Encoding Works
Base64 encoding works by taking binary data and dividing it into 6-bit chunks (since 2^6 = 64 possible values). Each 6-bit chunk is then mapped to one of 64 printable ASCII characters. When the input length isn't perfectly divisible by 3, padding characters (=) are added to the end.
For example, the text "Hello" is encoded as "SGVsbG8=" in Base64. Our tool uses JavaScript's built-in btoa()
and atob()
functions for encoding and decoding, ensuring compatibility and standards compliance.
Common Use Cases
Data URLs: Embed images, fonts, or other files directly in HTML/CSS using Base64-encoded data URLs. This reduces HTTP requests but increases file size.
API Authentication: Basic authentication headers often use Base64 to encode username:password combinations for HTTP requests.
Email Attachments: MIME email protocol uses Base64 to encode binary attachments into text format for transmission.
JSON/XML Data: When binary data needs to be included in JSON or XML documents, Base64 encoding ensures safe transmission.