Browser based
Base64 Encoder/Decoder
Encode text to Base64 or decode Base64 strings back to text. Fast, secure, and completely private.
Bidirectional conversion
Encode text to Base64 or decode Base64 back to text with one click.
Instant results
Convert instantly without delays. Copy results with a single click.
Privacy-first
All encoding happens in your browser. Your data never leaves your device.
In-depth guide
What is Base64 encoding
Base64 encoding converts binary data into ASCII text format using 64 characters (A-Z, a-z, 0-9, +, /). This encoding scheme makes binary data safe for transmission over text-based protocols like email, JSON, and URLs. Base64 is not encryption—it is simply a way to represent data.
Web developers use Base64 to embed images directly in HTML or CSS. Data URIs allow images to load without separate HTTP requests, reducing page load times. Small icons and logos work particularly well as Base64-encoded data URIs.
APIs often require Base64 encoding for authentication. Basic authentication headers combine username and password, then encode them in Base64. OAuth tokens and API keys sometimes use Base64 encoding for transmission.
Email attachments rely on Base64 encoding. SMTP protocol handles only text, so binary files must be encoded. Email clients automatically decode Base64 attachments when you download them.
Base64 increases data size by approximately 33%. Three bytes of binary data become four Base64 characters. This overhead is acceptable for small data but significant for large files.
How Base64 encoding works
Base64 encoding groups input data into 3-byte chunks. Each chunk contains 24 bits, which splits into four 6-bit groups. Each 6-bit group maps to one of 64 ASCII characters in the Base64 alphabet.
The Base64 alphabet uses A-Z (values 0-25), a-z (values 26-51), 0-9 (values 52-61), plus sign (value 62), and forward slash (value 63). This character set works reliably across different systems and protocols.
Padding handles input that is not a multiple of three bytes. The equals sign (=) pads the output to ensure proper length. One padding character means the last group had two bytes, two padding characters means one byte.
Decoding reverses the process. Each Base64 character converts back to its 6-bit value. Four characters combine into three bytes of original data. Padding characters are removed during decoding.
URL-safe Base64 variants replace problematic characters. Standard Base64 uses + and / which have special meaning in URLs. URL-safe Base64 substitutes - and _ to avoid conflicts.
Common Base64 use cases
Data URIs embed images and files directly in web pages. Using a Base64 Encoder converts image files to text strings that work in src attributes. This technique eliminates separate image requests and speeds up initial page loads.
JSON APIs transmit binary data as Base64 strings. File uploads, image processing, and document handling often require Base64 encoding. APIs cannot handle raw binary in JSON, so Base64 provides a text-safe alternative.
Authentication systems encode credentials for transmission. HTTP Basic Authentication combines username:password, then encodes in Base64. While not secure alone, it works with HTTPS to protect credentials.
Email systems encode attachments using Base64. MIME (Multipurpose Internet Mail Extensions) requires text-safe encoding for binary attachments. Base64 ensures files survive email transmission without corruption.
Configuration files store binary data as Base64 text. Certificates, keys, and encrypted data often appear as Base64 in config files. This encoding makes binary data easy to copy, paste, and version control.
Best practices for Base64
Use Base64 for small data only. The 33% size increase becomes problematic for large files. Images over 10KB should load as separate files rather than Base64 data URIs. Large Base64 strings slow page parsing.
Combine Base64 with compression when possible. Compress data before encoding to reduce the size penalty. Gzip compression works well with Base64-encoded content in HTTP responses.
Cache Base64-encoded resources appropriately. Data URIs cannot be cached separately from their containing document. Separate image files benefit from browser caching, while inline Base64 does not.
Validate Base64 strings before decoding. Invalid characters or incorrect padding cause decoding errors. Check string format and length before attempting to decode to avoid crashes.
Consider alternatives for large binary data. Modern APIs support multipart/form-data for file uploads. Binary protocols like gRPC handle binary data more efficiently than Base64-encoded JSON.
Frequently asked questions
Is Base64 encoding secure?
No. Base64 is encoding, not encryption. Anyone can decode Base64 strings. Use encryption (like AES) if you need security.
Why does Base64 make data larger?
Base64 uses 4 characters to represent 3 bytes of data, increasing size by about 33%. This is the cost of text-safe encoding.
Can I encode files?
This tool encodes text. For files, you would need to read the file as binary data first, which requires different handling.
What is the = padding for?
Padding ensures Base64 output length is a multiple of 4. It indicates how many bytes were in the final group.