Logo

Complete Tools

Search tools
Ctrl K
Favoritekofi

Base64 Encoder Decoder

Encode and decode Base64 strings and files online

Encode text and files to Base64 format or decode Base64 strings back to original content. Support for UTF-8 encoding and file uploads.

Categories
Text Tools, Encoder Tools

Input

Output

What is Base64 Encoder Decoder?

Base64 Encoder Decoder is a free online tool for encoding and decoding Base64 strings. Base64 is a binary-to-text encoding scheme that represents binary data in ASCII string format. This tool allows you to easily convert text to Base64, decode Base64 strings back to text, and even encode files to Base64 format.

Whether you're working with APIs, embedding images in HTML/CSS, or transmitting binary data, this tool makes Base64 encoding and decoding simple and fast.

What is Base64 Encoding?

Base64 is a group of binary-to-text encoding schemes that represent binary data (more specifically, sequences of 8-bit bytes) in sequences of 24 bits that can be represented by four 6-bit Base64 digits.

Why Use Base64?

Base64 encoding is commonly used when there is a need to encode binary data, especially when that data needs to be stored and transferred over media that are designed to deal with text.

Common uses:

  • Embedding images in HTML/CSS (Data URLs)
  • Email attachments (MIME)
  • Storing complex data in XML or JSON
  • Encoding binary data in URLs
  • Basic authentication in HTTP headers
  • Transferring binary data over text-based protocols

Base64 Character Set

Base64 uses 64 different characters:

  • A-Z (26 characters)
  • a-z (26 characters)
  • 0-9 (10 characters)
  • + and / (2 characters)
  • = (padding character)

How to use Base64 Encoder Decoder?

Text Encode/Decode

For encoding and decoding text:

  1. Select the "Text Encode/Decode" tab

  2. To Encode:

    • Paste your text in the input area
    • Click "Encode to Base64"
    • The Base64 encoded string appears in the output area
  3. To Decode:

    • Paste your Base64 string in the input area
    • Click "Decode from Base64"
    • The decoded text appears in the output area
  4. Use Copy to copy the result

File to Base64

For encoding files:

  1. Select the "File to Base64" tab

  2. Click "Choose File" and select any file from your computer

  3. The file is automatically encoded to Base64

  4. The Base64 string appears in the output area

  5. Use Copy to copy the Base64 string

Features

  • Bidirectional conversion - Encode and decode in both directions
  • UTF-8 support - Handles Unicode characters correctly
  • File encoding - Upload and encode any file type
  • Large text support - Handle long Base64 strings
  • Error handling - Clear error messages for invalid input
  • Monospace font - Easy-to-read Base64 output
  • Instant copy - Quick clipboard functionality
  • Browser-based - All processing happens locally

Understanding Base64 Encoding

How Base64 Works

Base64 encoding converts 3 bytes (24 bits) of binary data into 4 Base64 characters (24 bits):

  1. Take 3 bytes of input
  2. Split into 4 groups of 6 bits each
  3. Convert each 6-bit group to a Base64 character
  4. Add padding (=) if needed

Example: Encoding "Hello"

StepValue
Original textHello
Binary (ASCII)01001000 01100101 01101100 01101100 01101111
Grouped in 6-bit010010 000110 010101 101100 011011 000110 1111
Base64 indices18 6 21 44 27 6 60
Base64 encodedSGVsbG8=

Padding

When the input length isn't divisible by 3, padding characters (=) are added:

  • No padding: Input length divisible by 3
  • One =: Input has 2 bytes remaining
  • Two ==: Input has 1 byte remaining

Examples:

"A"   → "QQ=="
"AB"  → "QUI="
"ABC" → "QUJD"

Common Use Cases

1. Data URLs (Embedding Images)

Embed images directly in HTML/CSS:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA..." />
.logo {
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAA...);
}

2. HTTP Basic Authentication

Encode credentials for HTTP Basic Auth:

Username: user
Password: pass
Combined: user:pass
Base64: dXNlcjpwYXNz

Header: Authorization: Basic dXNlcjpwYXNz

3. JSON/XML Data Transmission

Encode binary data in JSON:

{
  "filename": "document.pdf",
  "content": "JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PC9UeXBlIC9DYXRhbG9nCi9QYWdlc...",
  "encoding": "base64"
}

4. Email Attachments (MIME)

Encode files for email transmission:

Content-Type: application/pdf; name="document.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="document.pdf"

JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PC9UeXBlIC9DYXRhbG9nCi9QYWdlc...

5. Storing Binary Data

Store binary data in text-based databases or configuration files:

const config = {
  logo: "data:image/png;base64,iVBORw0KGgoAAAANSUhEU...",
  certificate: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSU..."
};

Examples

Example 1: Simple Text

Input:

Hello, World!

Encoded:

SGVsbG8sIFdvcmxkIQ==

Example 2: Unicode Characters

Input:

你好世界 🌍

Encoded:

5L2g5aW95LiW55WMIPCfjI0=

Example 3: JSON Data

Input:

{"name":"John","age":30}

Encoded:

eyJuYW1lIjoiSm9obiIsImFnZSI6MzB9

Example 4: HTML Content

Input:

<h1>Title</h1>

Encoded:

PGgxPlRpdGxlPC9oMT4=

Base64 Variants

Standard Base64

  • Uses: A-Z, a-z, 0-9, +, /
  • Padding: =
  • RFC 4648

URL-Safe Base64

  • Uses: A-Z, a-z, 0-9, -, _
  • Padding: Optional
  • Safe for URLs and filenames

Base64 without padding

  • Same as standard but omits = padding
  • Shorter output
  • Some systems don't require padding

Tips for Best Results

  1. Unicode text: Our tool properly handles UTF-8 encoding for international characters

  2. Large files: While you can encode large files, consider server-side processing for very large files (>10MB)

  3. Security: Base64 is NOT encryption - it's just encoding. Don't use it for securing sensitive data

  4. Size increase: Base64 encoding increases data size by approximately 33%

  5. Line breaks: Some systems insert line breaks every 64 or 76 characters. Our tool removes these automatically

Common Issues and Solutions

Issue: Decoded text shows garbled characters

Solution: The Base64 string may not be valid or may use a different character encoding. Ensure the original encoding was UTF-8.


Issue: Getting "Invalid Base64 string" error

Solution: Check for:

  • Invalid characters in the Base64 string
  • Incorrect padding
  • Truncated Base64 data
  • Line breaks or spaces (our tool handles these)

Issue: Encoded output is too long

Solution: Base64 increases size by ~33%. This is normal. For large data, consider:

  • Compressing before encoding
  • Using binary transmission if possible
  • Chunking large files

Issue: Need URL-safe Base64

Solution: After encoding, replace:

  • + with -
  • / with _
  • Remove = padding (optional)

Security Considerations

Important: Base64 is encoding, not encryption

  • Not secure: Anyone can decode Base64
  • No protection: Provides no data security
  • Visibility: Encoded data is easily visible and decodable
  • Use case: Use for data transmission, not data protection

For security, use:

  • Encryption algorithms (AES, RSA)
  • Hashing (SHA-256, bcrypt)
  • HTTPS for transmission
  • Proper authentication and authorization

Base64 in Different Languages

JavaScript

// Encode
const encoded = btoa('Hello World');

// Decode
const decoded = atob('SGVsbG8gV29ybGQ=');

Python

import base64

# Encode
encoded = base64.b64encode(b'Hello World')

# Decode
decoded = base64.b64decode(b'SGVsbG8gV29ybGQ=')

PHP

// Encode
$encoded = base64_encode('Hello World');

// Decode
$decoded = base64_decode('SGVsbG8gV29ybGQ=');

Java

import java.util.Base64;

// Encode
String encoded = Base64.getEncoder().encodeToString("Hello World".getBytes());

// Decode
byte[] decoded = Base64.getDecoder().decode("SGVsbG8gV29ybGQ=");

Frequently Asked Questions

Q: Is Base64 encoding secure?

A: No, Base64 is not encryption and provides no security. It's simply a way to represent binary data in text format. Anyone can decode Base64 instantly.

Q: Why does Base64 make data larger?

A: Base64 converts 3 bytes into 4 characters, resulting in approximately 33% size increase. This is the trade-off for representing binary data in text format.

Q: Can I encode any file type?

A: Yes! Base64 can encode any file - images, PDFs, videos, executables, etc. However, very large files may be slow to process in the browser.

Q: What's the difference between Base64 and hexadecimal?

A: Hexadecimal uses 16 characters (0-9, A-F) and represents data more compactly than binary but less compactly than Base64. Base64 is more efficient for text transmission.

Q: Why do some Base64 strings have = at the end?

A: The equals signs (=) are padding characters added when the input length isn't divisible by 3. They ensure the output length is divisible by 4.

Q: Can I decode Base64 images?

A: Yes, but our text decoder works for text data. For images, you'd need to save the decoded binary data as a file. The "File to Base64" tab can encode images.

Q: Is there a size limit?

A: Browser memory is the main limitation. Modern browsers can handle several MB of text. For larger files, use server-side processing.

Privacy & Security

Your privacy is important to us:

  • No data is sent to any server
  • All encoding/decoding happens in your browser
  • Files are processed locally
  • No cookies or tracking
  • No account or login required
  • Completely free to use

Comments

Complete Tools
AboutTermsPrivacyContact

Copyright © 2022 - 2025 Complete Tools. Unless otherwise noted, all code MIT license.


Made with by Complete JavaScript