Bookmark this page for quick access to all tools

Base64 Encoder & Decoder

Encode text and files to Base64 or decode Base64 strings instantly—with file upload, URL-safe encoding, and image preview.

Base64 Encoder

About Base64 Encoding

Base64 is a binary-to-text encoding scheme that represents binary data in ASCII format. It's commonly used for embedding images in HTML/CSS, email attachments, and data URLs. Note: Base64 is NOT encryption—it's easily reversible and should not be used for security.

Our Base64 Encoder & Decoder is a comprehensive free tool for encoding text and files to Base64 or decoding Base64 strings back to their original format. Perfect for developers working with APIs, email systems, or data URLs, this tool supports file uploads up to 10MB, URL-safe encoding, image previews, and UTF-8 characters—all processed securely in your browser.

Common Use Cases for Base64 Encoding

  • Embed Images in HTML/CSS

    Convert images to Base64 data URLs for embedding directly in HTML or CSS without external file references.

  • Email Attachments

    Encode files as Base64 for MIME email attachments and ensure safe transmission over text-based protocols.

  • API Data Transfer

    Encode binary data for JSON APIs that don't support binary payloads, ensuring safe data transmission.

  • Configuration Files

    Store binary data or credentials in text-based config files like JSON, YAML, or environment variables.

  • URL Parameters

    Use URL-safe Base64 encoding to pass binary data in query strings without breaking URL syntax.

  • Testing & Development

    Generate Base64 test data for unit tests, mock APIs, or debugging data encoding issues.

Why Choose Our Base64 Converter?

File Upload Support

Upload any file (images, PDFs, documents) up to 10MB and encode to Base64 instantly

Image Preview

Visual preview for encoded/decoded images with show/hide toggle

URL-Safe Encoding

Option to replace +/= characters with -_ for URL-safe Base64 strings

Bidirectional Conversion

Switch between encode and decode modes with one click

UTF-8 Support

Proper handling of Unicode characters including emojis and special symbols

Size Calculator

Real-time display of output length and file size in KB

How to Use the Base64 Converter

Encode Text:

  1. Select "Encode" tab
  2. Enter or paste your text in the input area
  3. Optionally enable URL-safe encoding
  4. Copy or download the Base64 output

Encode Files:

  1. Select "Encode" tab
  2. Click the upload area and select your file (max 10MB)
  3. View image preview if applicable
  4. Copy the Base64 string or download as text file

Decode Base64:

  1. Select "Decode" tab
  2. Paste your Base64 string
  3. Enable URL-safe decoding if needed
  4. View decoded text or download decoded file

Understanding Base64 Encoding

Base64 encoding converts binary data into a text format using 64 ASCII characters:

  • Characters Used: A-Z (26), a-z (26), 0-9 (10), + and / (2) = 64 total
  • Padding: Uses = character for padding when needed
  • Size Increase: Encoded data is ~33% larger (4 characters for every 3 bytes)
  • URL-Safe Variant: Replaces + with -, / with _, and removes = padding

Example:

Text: Hello World
Base64: SGVsbG8gV29ybGQ=
URL-Safe: SGVsbG8gV29ybGQ

Common Use Cases

Data URLs for Images

Embed images directly in HTML/CSS using data URLs: data:image/png;base64,iVBORw0KG...

JSON API Payloads

Send binary files through JSON APIs that only support text data

Email Attachments (MIME)

Encode file attachments for email transmission using MIME format

Configuration Storage

Store binary data in text-based config files (JSON, YAML, ENV)

Code Examples

JavaScript

// Encode
const text = "Hello World";
const encoded = btoa(text); // SGVsbG8gV29ybGQ=

// Decode
const decoded = atob(encoded); // Hello World

// URL-Safe Encode
const urlSafe = encoded.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');

Python

import base64

# Encode
text = "Hello World"
encoded = base64.b64encode(text.encode()).decode()

# Decode
decoded = base64.b64decode(encoded).decode()

# URL-Safe
url_safe = base64.urlsafe_b64encode(text.encode()).decode()

PHP

<?php
// Encode
$text = "Hello World";
$encoded = base64_encode($text);

// Decode
$decoded = base64_decode($encoded);
?>

Frequently Asked Questions

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into ASCII text format using 64 characters (A-Z, a-z, 0-9, +, /). It's commonly used to encode images, files, or binary data for transmission over text-based protocols like HTTP, email (MIME), or JSON APIs. The encoded data is approximately 33% larger than the original.

Is Base64 encoding secure or encrypted?

No! Base64 is NOT encryption or security. It's simply an encoding method that makes binary data text-readable. Anyone can decode Base64 strings instantly. Never use Base64 to hide sensitive information like passwords or API keys. For security, use proper encryption algorithms like AES, RSA, or bcrypt.

What is URL-safe Base64 encoding?

URL-safe Base64 replaces characters that have special meaning in URLs. Standard Base64 uses + and / which can break URLs. URL-safe encoding replaces + with - (minus), / with _ (underscore), and removes padding = characters. This is essential for passing Base64 data in query parameters or URL paths.

Can I encode files to Base64?

Yes! Our tool supports uploading any file type up to 10MB. Simply click the upload area in Encode mode, select your file, and it will be converted to Base64. For images, you'll see a preview. You can then copy the Base64 string or download it as a text file for use in your code or APIs.

Why does Base64 make files larger?

Base64 encoding increases file size by approximately 33% because it represents 3 bytes of binary data using 4 ASCII characters. For example, a 100KB image becomes ~133KB when Base64-encoded. This is the trade-off for making binary data text-safe. Use Base64 only when necessary (e.g., data URLs, JSON APIs).

How do I decode a Base64 image?

Paste the Base64 string in Decode mode. If it's an image, our tool will automatically detect it and show a preview. You can download the decoded image file by clicking 'Download'. For data URLs (starting with data:image/...), remove the data URL prefix and paste only the Base64 part after the comma.