Free Online Base64 Encoder & Decoder
Fast, secure, and private. All processing happens in your browser. Your data never leaves your device.
100% Client-Side Privacy
All encoding and decoding happens directly in your browser. Your files and data are never uploaded to any server. Everything stays on your device.
Powerful Features
Supports text, files, and images up to 10MB. URL-safe mode for web applications. Line-by-line processing for batch operations. One-click copy to clipboard.
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into a text format using 64 ASCII characters. It's widely used across the internet and software development for encoding data that needs to be stored or transferred over media designed to handle text.
When to Use Base64?
- Embedding images directly in HTML or CSS (data URIs)
- Sending binary data over text-based protocols (email, JSON APIs)
- Encoding credentials for HTTP Basic Authentication
- Storing complex data in URLs or cookies
- Encoding binary attachments in email (MIME)
How Does It Work?
Base64 encoding divides input data into groups of 3 bytes (24 bits), then splits these into 4 groups of 6 bits each. Each 6-bit group is mapped to one of 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). If the input length isn't divisible by 3, padding characters (=) are added to the output.
Code Examples
Learn how to encode and decode Base64 in different programming languages:
JavaScript (Browser)
// Encode
const encoded = btoa('Hello World');
console.log(encoded); // SGVsbG8gV29ybGQ=
// Decode
const decoded = atob('SGVsbG8gV29ybGQ=');
console.log(decoded); // Hello World
Python
import base64 # Encode encoded = base64.b64encode(b'Hello World') print(encoded) # b'SGVsbG8gV29ybGQ=' # Decode decoded = base64.b64decode(b'SGVsbG8gV29ybGQ=') print(decoded) # b'Hello World'
Java
import java.util.Base64;
// Encode
String encoded = Base64.getEncoder()
.encodeToString("Hello World".getBytes());
System.out.println(encoded); // SGVsbG8gV29ybGQ=
// Decode
byte[] decoded = Base64.getDecoder()
.decode("SGVsbG8gV29ybGQ=");
System.out.println(new String(decoded)); // Hello World
cURL (Command Line)
# Encode echo -n 'Hello World' | base64 # SGVsbG8gV29ybGQ= # Decode echo 'SGVsbG8gV29ybGQ=' | base64 -d # Hello World
Frequently Asked Questions
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It's commonly used to encode data that needs to be stored or transferred over media designed to handle text.
Yes! All processing happens in your browser (client-side). No data is sent to any server. Your files and text never leave your device, ensuring complete privacy and security.
The maximum file size is 10MB. This limit ensures optimal browser performance while handling most common use cases. For larger files, consider using command-line tools or server-side solutions.
URL-safe Base64 (RFC 4648) replaces + with - and / with _ to avoid conflicts with URL special characters. This is useful when encoding data for use in URLs, filenames, or HTTP headers.
Yes! You can encode any file including images (JPEG, PNG, GIF, SVG, etc.) up to 10MB. The resulting Base64 string can be used in data URIs for embedding images directly in HTML, CSS, or JSON.
Line-by-line mode processes each line of input separately, encoding or decoding them individually. This is useful for batch processing multiple values at once, with each line producing a separate output line.
Base64 encoding increases data size by approximately 33% because it represents 3 bytes of binary data using 4 ASCII characters. This overhead is the trade-off for making binary data safe for text-based systems.
No! Base64 is encoding, not encryption. It's easily reversible and provides no security. Anyone can decode Base64 data. For security, use proper encryption algorithms like AES before encoding.
Standard Base64 uses 64 characters: A-Z (26), a-z (26), 0-9 (10), + (1), and / (1). The = character is used for padding. URL-safe Base64 replaces + with - and / with _.
If the input contains invalid Base64 characters or improper formatting, the decoder will show an error. Make sure your input only contains valid Base64 characters (A-Z, a-z, 0-9, +, /, =) or their URL-safe equivalents.
Encode your file, then use the format: data:[MIME-type];base64,[encoded-data]. For example: data:image/png;base64,iVBORw0KG... This allows you to embed files directly in HTML or CSS without external resources.
This tool works in all modern browsers: Chrome, Firefox, Safari, Edge, Opera, and mobile browsers. It requires JavaScript enabled and uses standard Web APIs (FileReader, btoa, atob, TextEncoder).
Base64 Tool in Your Language
Access this tool in your preferred language for the best experience: