Base64 Encoder / Decoder

Encode and decode text or files to/from Base64 format. Perfect for API testing, embedding images, and debugging. All processing happens in your browser.

💡 Tip: Press Ctrl+Enter to encode

What is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It's commonly used to encode data when transmitting over media designed to handle text, such as email or HTTP. Base64 encoding converts binary data into a set of 64 different ASCII characters (A-Z, a-z, 0-9, +, /).

This tool allows you to encode text or files into Base64 format, or decode Base64 strings back to their original form. It's particularly useful for embedding images in HTML/CSS, API authentication, data URIs, and debugging.

How to Use This Tool

Encoding (Text → Base64)

  1. Enter or paste your text in the input field
  2. Click "Encode" button or press Ctrl+Enter
  3. Copy or download the Base64 output

Decoding (Base64 → Text)

  1. Paste your Base64 string in the input field
  2. Click "Decode" button
  3. View the decoded text or image in the output

File Encoding

  1. Switch to "File Mode"
  2. Drag & drop or select a file
  3. Get Base64 output instantly
  4. Images show preview automatically

Tips & Features

  • Supports data URLs (data:image/png;base64,...)
  • Auto-detects and previews images
  • Maximum file size: 5MB
  • Keyboard shortcut: Ctrl+Enter to encode

Common Use Cases

Data URIs

Embed images directly in HTML or CSS without external files

API Authentication

HTTP Basic Auth uses Base64 to encode credentials

Email Attachments

MIME encodes attachments in Base64 format

JSON Web Tokens

JWT tokens use Base64URL encoding for payload

Binary Data Transfer

Safely transfer binary data over text protocols

Debugging

Decode Base64 strings to inspect their content

Understanding Base64 Encoding Format

Base64 encoding works by converting binary data (which computers understand as sequences of 8-bit bytes) into a text format using only 64 specific ASCII characters. These 64 characters consist of uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), plus (+), and forward slash (/), with equals signs (=) used as padding at the end when needed.

The encoding process takes three bytes of binary data (24 bits) and divides them into four 6-bit groups. Each 6-bit group represents a number from 0-63, which maps to one of the 64 Base64 characters. This is why Base64-encoded data is roughly 33% larger than the original - you're using 4 characters to represent 3 bytes of data. For example, the text "Man" encodes to "TWFu" in Base64.

When the input data length isn't perfectly divisible by 3, padding is added. The equals sign (=) serves as padding to make the output length a multiple of 4. You'll see one or two equals signs at the end of Base64 strings when the original data's byte count wasn't divisible by 3. This padding is essential for decoders to correctly reconstruct the original data.

It's important to note that Base64 is an encoding scheme, not encryption or compression. It doesn't make data secure (anyone can decode it) and actually increases size by about 33%. Its purpose is data representation - converting binary data into a format that's safe for transmission over text-based protocols like email, JSON, or URLs.

When to Use Base64 Encoding

🖼️ Embedding Images in HTML/CSS

Convert images to Base64 data URIs to embed them directly in HTML or CSS files. This eliminates separate image files and HTTP requests, improving load times for small icons and logos. Particularly useful for email templates where external images may be blocked.

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

🔐 HTTP Basic Authentication

HTTP Basic Auth encodes credentials (username:password) in Base64 for transmission in the Authorization header. While not secure by itself (always use HTTPS!), it's a standard authentication method for APIs and web services.

Authorization: Basic dXNlcjpwYXNzd29yZA==

📧 Email Attachments (MIME)

Email protocols (SMTP) were originally designed for 7-bit ASCII text only. MIME (Multipurpose Internet Mail Extensions) uses Base64 to encode binary attachments (PDFs, images, documents) so they can be safely transmitted via email. This is why email attachments are encoded during sending and decoded when received.

🎫 JSON Web Tokens (JWT)

JWTs use Base64URL encoding (a URL-safe variant of Base64) to encode the header and payload. This allows tokens to be safely transmitted in URLs, HTTP headers, and cookies without special character issues. Decode JWT parts to inspect claims and metadata during debugging.

🔄 API Data Transfer

When APIs need to transmit binary data (images, PDFs, audio) in JSON responses, Base64 encoding allows binary content to be included as a string value. This enables single-request API calls that include both metadata (JSON) and file content (Base64) without requiring multipart uploads.

🐛 Debugging & Analysis

Developers frequently encounter Base64 strings in logs, tokens, API responses, or database records. Decode these strings to inspect their actual content, verify data integrity, or troubleshoot integration issues. Essential for debugging authentication tokens, encrypted data, and binary payloads.

Frequently Asked Questions

Is Base64 encoding secure or encrypted?

No, Base64 is not encryption or security - it's simply encoding for data representation. Anyone with a Base64 decoder (which is freely available everywhere) can decode it back to the original data. Never use Base64 alone to protect sensitive information. If you need security, use proper encryption (AES, RSA, etc.) and transmit over HTTPS. Base64 is about compatibility, not confidentiality.

Why does Base64 make files larger?

Base64 increases file size by approximately 33% because it uses 4 characters to represent 3 bytes of data. This overhead is the trade-off for representing binary data in a text-safe format. For example, a 3KB binary file becomes 4KB when Base64-encoded. This size increase is why Base64 is best for small files like icons or logos, not large images or videos where the overhead becomes significant.

What's the difference between Base64 and Base64URL?

Base64URL is a URL-safe variant of Base64. Standard Base64 uses + and / characters, which have special meaning in URLs and must be percent-encoded. Base64URL replaces these with - (minus) and _ (underscore), and omits padding = characters. This makes Base64URL strings safe to use directly in URLs, filenames, and cookies without encoding. JWTs use Base64URL for this reason.

Can I decode any Base64 string?

You can decode valid Base64 strings, but the result might not be human-readable. Base64 can encode any binary data - text, images, PDFs, audio, etc. If you decode an image, you'll get binary data that needs to be saved as an image file to view. If you decode text, you'll see the original text. Our tool automatically detects and previews images from Base64 data URIs. Invalid Base64 strings (wrong characters, incorrect padding) will produce decoding errors.

Should I use Base64 for storing images in databases?

Generally, no. Storing images as Base64 in databases has significant downsides: 33% size overhead increases storage costs and query performance, no native image processing capabilities, slower retrieval times, and difficulty caching. Best practice is storing images as files on disk or object storage (like AWS S3) and storing only the file path in your database. Use Base64 for embedding small icons directly in HTML/CSS, not for database storage.

What's the maximum file size I can encode?

Our tool supports files up to 5MB for client-side encoding. This limit prevents browser memory issues and ensures smooth performance. For larger files, the encoded Base64 string becomes very long (remember the 33% overhead) and can cause browser slowdowns or crashes. If you need to encode files larger than 5MB, consider using command-line tools or server-side encoding instead.

What are data URIs and when should I use them?

Data URIs embed file content directly in HTML using the format data:[mime-type];base64,[data]. They're excellent for small resources like icons, logos, or loading spinners because they eliminate HTTP requests, improving page load time. However, they have downsides: can't be cached separately, increase HTML size, and aren't suitable for large files. Best practice: use data URIs for images under 10KB, use regular image files for everything else.

Is Base64 encoding platform-independent?

Yes, absolutely. Base64 is a standardized encoding scheme (RFC 4648) that works identically across all platforms, operating systems, and programming languages. A Base64 string encoded on Windows can be decoded on Linux, Mac, mobile devices, or any other platform. This universal compatibility is one of Base64's key advantages and why it's used so extensively in cross-platform data exchange.

Privacy & Security

All encoding and decoding happens entirely in your browser using JavaScript. Your data is never sent to any server, never stored, and never leaves your device. This tool runs 100% client-side, ensuring complete privacy and security for your files and data.

Whether you're encoding sensitive documents, API credentials, or confidential images, everything stays local. Your privacy is guaranteed by design - we literally cannot see your data because it never reaches our servers. Perfect for working with confidential business data, personal files, or any sensitive information.

Why Use Our Base64 Encoder?

Our Base64 encoder combines speed, simplicity, and security in one free tool. Unlike many online encoders that require uploads to servers (creating privacy risks), ours processes everything locally in your browser. Encode text, decode Base64 strings, or convert entire files up to 5MB - all instantly and securely.

The tool automatically detects image data and provides instant previews, supports data URIs for easy embedding, and offers both text and file modes for maximum flexibility. Whether you're debugging JWT tokens, creating data URIs for CSS, testing API authentication, or encoding files for transmission, our encoder handles it effortlessly.

Completely free, no registration, no file size limits (up to 5MB), no usage restrictions, and no tracking. Just fast, reliable Base64 encoding and decoding whenever you need it, with absolute privacy guaranteed.