Base64 Encode/Decode

Encode text to Base64 or decode Base64 strings. Essential for data transmission, APIs, and web development.

What It Does

A Base64 Encoder/Decoder is a utility that converts text and binary data to and from Base64 encoding. Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format using 64 printable characters (A-Z, a-z, 0-9, +, /). This encoding is essential for transmitting binary data over text-based protocols like email, JSON, or URLs, where binary data might be corrupted or misinterpreted. It's widely used for embedding images in HTML/CSS, encoding authentication credentials, and safely transmitting data in APIs.

Key Features:

  • Bidirectional conversion: encode text to Base64 and decode Base64 to text
  • Support for UTF-8 text encoding for international characters
  • URL-safe Base64 encoding variant for query parameters and paths
  • File encoding support for images, documents, and binary files
  • Automatic character set detection and conversion
  • Copy encoded/decoded output with one click
  • Real-time encoding/decoding as you type
  • Display of encoded data size compared to original

How To Use

Encoding and decoding Base64 data is simple and instant. Use this tool for safely transmitting data, embedding resources, or decoding encoded strings.

1

Choose Encode or Decode

Select whether you want to encode plain text to Base64 or decode Base64 back to readable text. The tool supports bidirectional conversion.

2

Enter Your Data

For encoding: paste or type any text, including special characters and emojis. For decoding: paste the Base64 encoded string you want to convert back to plain text.

3

Select Encoding Options

Choose standard Base64 or URL-safe Base64 (which replaces + with - and / with _ for use in URLs). For text, ensure UTF-8 encoding for proper international character support.

4

View Results Instantly

The conversion happens in real-time. See the encoded/decoded output immediately in the results area, along with the size of the output data.

5

Copy or Use the Output

Click the copy button to copy the result to your clipboard, then paste it into your application, API, or configuration file.

Pro Tips

  • Base64 increases data size by approximately 33% - use it only when necessary
  • Use URL-safe Base64 when encoding data for URLs to avoid special character issues
  • Remember that Base64 encoding is NOT encryption - it's easily reversible
  • For binary files, encoding can result in very large strings
  • When decoding, ensure the string is valid Base64 to avoid errors
  • UTF-8 encoding is automatically handled for international characters

Benefits

Safely transmit binary data through text-only protocols
Embed images directly in HTML or CSS without external files
Encode authentication credentials for HTTP Basic Auth headers
Share binary data in JSON APIs without corruption
Test Base64-encoded data in development and debugging
Reduce HTTP requests by embedding small images as data URIs
Convert between text and Base64 instantly without server calls

Use Cases

HTTP Basic Authentication

Encode username:password combinations for HTTP Basic Auth headers in API requests.

Encode "username:password" to include in Authorization header

Data URI for Images

Convert small images to Base64 for embedding directly in HTML or CSS, reducing HTTP requests.

Create data:image/png;base64,... URIs for inline images

Email Attachments

Encode file attachments in Base64 for transmission in MIME email messages.

Encode PDF or image files for email APIs

JSON API Data Transmission

Include binary data like images or documents in JSON API payloads.

Send user profile pictures in JSON registration requests

Configuration Files

Store binary data or credentials in text-based configuration files.

Encode API keys or certificates in YAML/JSON configs

QR Code Generation

Encode data for QR codes or decode QR code data for processing.

Encode URLs or vCard data for QR code libraries

Code Examples

Simple Text Encoding

Basic text to Base64 encoding example

text
Input: Hello World
Base64: SGVsbG8gV29ybGQ=

HTTP Auth Header

Base64 encoded credentials for HTTP Basic Auth

text
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Data URI Image

Embedding Base64 image in HTML

html
<img src="data:image/png;base64,iVBORw0KGgoAAAANS..." />

Frequently Asked Questions

1 Is Base64 encoding secure or encrypted?
No, Base64 is NOT encryption or security—it's simply an encoding scheme. Anyone can easily decode Base64 strings using tools like this one. Base64 makes binary data text-safe for transmission, but it provides zero security. Never use Base64 as a security measure for protecting sensitive data like passwords or credit card numbers. If you need security, use proper encryption algorithms like AES or RSA. Base64 is often used after encryption to make encrypted bytes text-safe, but the encoding itself provides no protection.
2 Why does Base64 make data larger?
Base64 encoding increases data size by approximately 33% (4/3 ratio) because it represents every 3 bytes of input with 4 ASCII characters. This trade-off is necessary to ensure binary data can be safely transmitted through systems that only support text. The size increase is the cost of using text-safe encoding. For example, a 100KB image becomes about 133KB when Base64 encoded. Despite the size increase, Base64 is still useful for embedding small resources, as it can eliminate separate HTTP requests and simplify data handling.
3 What's the difference between standard and URL-safe Base64?
Standard Base64 uses the character set A-Z, a-z, 0-9, +, and /. The + and / characters can cause problems in URLs, where they have special meanings (+ is often interpreted as a space, / is a path separator). URL-safe Base64 replaces + with - (hyphen) and / with _ (underscore), making it safe to use in URLs, filenames, and query parameters. Both variants produce the same decoded output. Use standard Base64 for general purposes and URL-safe Base64 when the encoded string will appear in a URL or filename.
4 Can I encode files with Base64?
Yes, any file can be Base64 encoded—images, documents, audio, video, or any binary data. However, consider the 33% size increase and the practical limits of handling large strings. Base64 encoding is practical for small files (under 1MB) like icons, thumbnails, or small PDFs. For larger files, direct binary transmission is usually more efficient. Common use cases include embedding small images in HTML/CSS as data URIs, including files in JSON APIs, and attaching documents to emails via MIME encoding.
5 Why am I getting invalid Base64 errors when decoding?
Invalid Base64 errors occur when the input string contains characters outside the Base64 alphabet, has incorrect padding, or is corrupted. Common causes include: copying incomplete strings (Base64 length should be divisible by 4), mixing standard and URL-safe variants, including whitespace or line breaks (which may need to be removed), or attempting to decode non-Base64 data. Ensure you've copied the complete encoded string and that you're using the correct Base64 variant (standard vs URL-safe). Our decoder attempts to handle minor formatting issues automatically.

Related Tools