Base64 Encoder Decoder Online

Use our free Base64 encoder decoder online to quickly encode text to Base64 or decode Base64 back to readable text. This browser-based tool works instantly and is perfect for developers, API testing, and safe data transmission.

✔ Runs entirely in your browser • ✔ No uploads • ✔ Free forever
Copied to clipboard!

How to Encode Text to Base64 Online for Free

What It Does

The Base64 encoder takes plain text and converts it into a Base64 encoded string. It transforms each 3 bytes of data into 4 ASCII characters using the Base64 alphabet (A-Z, a-z, 0-9, +, /, and = for padding).

When to Use It

  • Embedding images in HTML/CSS as data URLs
  • Encoding binary data for JSON or XML transmission
  • Creating basic authentication headers for APIs
  • Storing binary data in text-based databases
  • Encoding email attachments (MIME)

Example

Input: Hello World
Output: SGVsbG8gV29ybGQ=

Common Errors

  • Non-ASCII characters – Base64 works with bytes; ensure proper UTF-8 encoding first
  • Very large input – Browser may slow down; consider chunking for huge data

How to Decode a Base64 String Back to Text

What It Does

The Base64 decoder takes a Base64 encoded string and converts it back to its original plain text. It reverses the encoding process by mapping each 4 characters back to 3 bytes of original data.

When to Use It

  • Decoding JWT tokens and API authentication headers
  • Extracting original data from data URLs
  • Reading encoded email attachments
  • Processing Base64 data from web APIs
  • Debugging encoded database fields

Example

Input: SGVsbG8gV29ybGQ=
Output: Hello World

Common Errors

  • Invalid characters – Base64 strings can only contain A-Z, a-z, 0-9, +, /, =
  • Incorrect padding – Missing or extra = at the end
  • URL-safe vs standard – Using -_ instead of +/ requires conversion

Common Base64 Decode Errors & Fixes

⚠️ Invalid Character Error

Error message: "Invalid character", "Non-base64 character", or similar

Cause: The Base64 string contains characters outside the valid alphabet (A-Z, a-z, 0-9, +, /, =). This often happens when copying strings that include newlines, spaces, or URL-safe variants.

✅ Fix: Remove whitespace and newlines first. If using URL-safe Base64 (with - and _), replace - with + and _ with / before decoding.
Bad: SGVsbG8gV29ybGQ= (contains space)
Good: SGVsbG8gV29ybGQ=
⚠️ Incorrect Padding Error

Error message: "Invalid padding", "Incorrect padding", or "Base64 string length not a multiple of 4"

Cause: Base64 strings must have a length that's a multiple of 4. Padding characters (=) are added to make this happen. Missing or extra padding causes errors.

✅ Fix: Add the correct padding. The string length should be divisible by 4. If length % 4 = 1, it's invalid. If length % 4 = 2, add ==. If length % 4 = 3, add =.
Bad: SGVsbG8gV29ybGQ (missing =)
Fixed: SGVsbG8gV29ybGQ=
⚠️ Corrupted String Error

Error message: "Corrupted data", "Invalid base64 string", or gibberish output

Cause: The Base64 string has been truncated, modified, or contains characters from a different encoding. Sometimes happens when copying from PDFs or emails.

✅ Fix: Verify the original source. Check for missing characters, line breaks, or invisible characters. Re-copy from the original source if possible.
⚠️ URL-Safe Base64 vs Standard Base64

Error message: "Invalid character" when decoding strings with - or _

Cause: URL-safe Base64 uses - instead of + and _ instead of / to be safe in URLs. Standard Base64 decoders don't recognize these characters.

✅ Fix: Convert URL-safe Base64 to standard before decoding: replace - with +, _ with /, then add padding.
URL-safe: SGVsbG8gV29ybGQ-
Convert to standard: SGVsbG8gV29ybGQ/
Add padding: SGVsbG8gV29ybGQ=

Base64 Encoding in Popular Programming Languages

Use these code examples to implement Base64 encoding and decoding in your own applications:

JavaScript (Node.js & Browser)

// Encode to Base64 (Browser)
const text = "Hello World";
const encoded = btoa(text);
const decoded = atob(encoded);
// encoded = "SGVsbG8gV29ybGQ="

// Node.js
const encodedNode = Buffer.from(text).toString('base64');
const decodedNode = Buffer.from(encodedNode, 'base64').toString();

// Handle Unicode properly
function unicodeToBase64(str) {
  return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
    function(match, p1) { return String.fromCharCode('0x' + p1); }));
}

Python

import base64

# Encode string to Base64
text = "Hello World"
text_bytes = text.encode('utf-8')
base64_bytes = base64.b64encode(text_bytes)
base64_string = base64_bytes.decode('utf-8')
# base64_string = "SGVsbG8gV29ybGQ="

# Decode Base64 to string
decoded_bytes = base64.b64decode(base64_string)
decoded_text = decoded_bytes.decode('utf-8')
# decoded_text = "Hello World"

# URL-safe Base64 (for URLs and filenames)
url_safe = base64.urlsafe_b64encode(text_bytes)

Java

import java.util.Base64;

public class Base64Example {
  public static void main(String[] args) {
    String text = "Hello World";

    // Encode
    String encoded = Base64.getEncoder().encodeToString(text.getBytes());
    // encoded = "SGVsbG8gV29ybGQ="

    // Decode
    byte[] decodedBytes = Base64.getDecoder().decode(encoded);
    String decoded = new String(decodedBytes);
    // decoded = "Hello World"

    // URL-safe version
    String urlSafe = Base64.getUrlEncoder().encodeToString(text.getBytes());
  }
}

C# (.NET)

using System;
using System.Text;

public class Base64Example {
  public static void Main() {
    string text = "Hello World";

    // Encode
    byte[] textBytes = Encoding.UTF8.GetBytes(text);
    string encoded = Convert.ToBase64String(textBytes);
    // encoded = "SGVsbG8gV29ybGQ="

    // Decode
    byte[] decodedBytes = Convert.FromBase64String(encoded);
    string decoded = Encoding.UTF8.GetString(decodedBytes);
    // decoded = "Hello World"
  }
}

PHP

<?php
$text = "Hello World";

// Encode to Base64
$encoded = base64_encode($text);
// $encoded = "SGVsbG8gV29ybGQ="

// Decode from Base64
$decoded = base64_decode($encoded);
// $decoded = "Hello World"
?>

Ruby

require 'base64'

text = "Hello World"

# Encode to Base64
encoded = Base64.encode64(text)
# encoded = "SGVsbG8gV29ybGQ=\n" (includes newline)

# Decode from Base64
decoded = Base64.decode64(encoded)
# decoded = "Hello World"

# Strict encoding (no newlines)
strict_encoded = Base64.strict_encode64(text)

Quick Base64 Examples

Plain Text Base64 Encoded
Hello SGVsbG8=
Hello World SGVsbG8gV29ybGQ=
Base64 Encoding QmFzZTY0IEVuY29kaW5n
123456789 MTIzNDU2Nzg5

Other Ways People Search for This Tool

This Base64 tool covers all these common search intents:

base64 encode text online base64 decode online free base64 string converter encode to base64 free decode base64 string base64 encoding tool base64 text converter online base64 encoder base64 to text converter base64 decode text free convert text base64 online base64 cipher online

Encode or decode Base64 strings instantly in your browser — no server, no uploads, completely private.

Frequently Asked Questions

What is Base64 encoding used for?

Base64 encoding is commonly used to transmit binary data over text-based protocols like HTTP, email (MIME), and XML. It's essential for embedding images in HTML/CSS, encoding authentication tokens, and safely transmitting data that may contain special characters.

Is my data safe with this Base64 tool?

Yes! All encoding and decoding happens locally in your browser. Your text never leaves your device, ensuring complete privacy and security. No data is uploaded to any server.

How do I decode a Base64 string online?

To decode a Base64 string online, paste it into this free tool and click 'Decode Base64'. It will instantly convert it to text if it's properly formatted.

Why does Base64 end with = or ==?

The equals sign (=) is padding. Base64 requires the output length to be a multiple of 4. When the input doesn't divide evenly into 3-byte chunks, = or == is added as padding.

What's the difference between Base64 and URL-safe Base64?

Standard Base64 uses + and /, which have special meanings in URLs. URL-safe Base64 replaces + with - and / with _ so the string can be used in URLs without encoding.

Can Base64 be decrypted?

Base64 is encoding, not encryption. It can be easily decoded by anyone. Don't use Base64 to protect sensitive data – it's for data transmission, not security.

Is this Base64 tool completely free to use?

Yes! This Base64 encoder and decoder is 100% free with no hidden costs, registration requirements, or usage limits. It will always remain free for developers and users.

What types of data can I encode with Base64?

You can encode any text data including strings, JSON, XML, and even binary data representations. Common uses include encoding images for data URLs, encoding authentication tokens, and preparing data for API transmission.

Does Base64 encoding increase data size?

Yes, Base64 encoding typically increases data size by about 33%. This is because it converts 3 bytes of binary data into 4 ASCII characters. The trade-off is necessary for safe transmission over text-based systems.

Can I use this tool for API testing?

Absolutely! This tool is perfect for API testing and development. You can quickly encode/decode authentication tokens, test data payloads, and prepare Base64 encoded content for HTTP requests.