How to Convert Base64 to Text

A comprehensive guide to decoding Base64 strings with examples and step-by-step instructions

Looking for a quick way to decode Base64?
Our free online converter handles the decoding instantly, with complete privacy.
Try Our Decoder

What is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It converts binary data into a set of 64 characters (hence the name "Base64") that can be safely transmitted over media designed for textual data. These 64 characters consist of uppercase letters A-Z, lowercase letters a-z, numbers 0-9, and the symbols '+' and '/' (with '=' used for padding).

When binary data needs to be stored or transferred over media that is designed to handle text (like email systems or APIs), Base64 encoding provides a way to convert that binary data into a text format. This is why you'll often see Base64-encoded strings in various technical contexts, from email attachments to web tokens and data URIs.

Key Point

Base64 encoding increases the size of the data by approximately 33% (since every 3 bytes of data are represented as 4 bytes in Base64), but it ensures that the data can be properly transmitted in text-based systems without corruption.

Why Would You Need to Decode Base64?

There are numerous scenarios where you might encounter Base64-encoded strings and need to convert them back to their original form:

  • Working with APIs - Many APIs transmit data in Base64 format, especially for binary content like images or files.
  • Email attachments - Files attached to emails are often Base64-encoded within the MIME format.
  • Web development - Base64 strings are used in data URIs for embedding images directly in HTML/CSS.
  • JWT (JSON Web Tokens) - Used for authentication, these tokens contain Base64-encoded segments.
  • Decoding headers and signatures - Various security implementations use Base64 for encoding certificates and signatures.
  • Analyzing encoded data - Security professionals often need to decode suspicious Base64 strings in logs or network traffic.

Converting Base64 back to text (or other forms of data) allows you to read, modify, or use the original information in its intended format.

Using an Online Base64 to Text Converter

The easiest and most straightforward way to decode Base64 is to use an online conversion tool. Here's how to use our Base64 decoder:

  1. Go to Base64Converter.org
  2. Click on the "Decode" tab (it should be the second tab at the top)
  3. Paste your Base64-encoded string into the input field
  4. The decoded text will automatically appear in the output field
  5. Click "Copy to Clipboard" if you want to use the decoded text elsewhere
Security Advantage

Our Base64 decoder processes all data directly in your browser using JavaScript. Your Base64 strings are never sent to any server, ensuring complete privacy and security, especially important when dealing with sensitive information.

Special Options for Base64 Decoding

When decoding Base64, you might need to consider these options:

  • URL-safe Base64 - If you're working with Base64 that was used in URLs, it might use '-' and '_' instead of '+' and '/'. Our tool has an option to handle URL-safe Base64.
  • Padding - Standard Base64 uses '=' characters at the end for padding. Some implementations might omit these, but our decoder can handle Base64 strings with or without padding.
  • Line breaks - Some Base64 implementations insert line breaks (usually every 76 characters). Our tool automatically removes these before decoding.

Manual Base64 Decoding: Step-by-Step

While online tools are convenient, understanding how Base64 decoding works can be valuable. Here's a simplified explanation of the manual decoding process:

  1. Character to Value Mapping - Each Base64 character maps to a 6-bit value (0-63).
  2. Grouping Bits - Four Base64 characters (24 bits) are decoded into three 8-bit bytes.
  3. Handling Padding - '=' characters indicate that the final group has fewer than three bytes.

Base64 Decoding Example

Base64 String:
SGVsbG8gV29ybGQh
Decoded Text:
Hello World!

Breakdown of the decoding process:

  1. 'S' = 18, 'G' = 6, 'V' = 21, 's' = 44 → 18 (6 bits), 6 (6 bits), 21 (6 bits), 44 (6 bits)
  2. Combine bits: 010010 000110 010101 101100 → 01001000 01100101 01101100
  3. Convert to ASCII: 72 (H), 101 (e), 108 (l)
  4. Continue for remaining characters...
Important Note

Manual decoding is complex and error-prone, especially for large strings. For practical purposes, it's almost always better to use an automated tool or library function to decode Base64 correctly.

Decoding Base64 in Different Programming Languages

Most programming languages provide built-in functions or libraries for Base64 decoding. Here are examples in some popular languages:

JavaScript

// Decode Base64 to text
const decodedText = atob('SGVsbG8gV29ybGQh');
console.log(decodedText); // Output: Hello World!

// For Unicode strings, use this approach:
function decodeBase64(str) {
  return decodeURIComponent(atob(str).split('').map(function(c) {
    return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
  }).join(''));
}

// Decode Base64 to binary (Uint8Array)
function base64ToUint8Array(base64) {
  const binary = atob(base64);
  const bytes = new Uint8Array(binary.length);
  for (let i = 0; i < binary.length; i++) {
    bytes[i] = binary.charCodeAt(i);
  }
  return bytes;
}

Python

import base64

# Decode Base64 to text
encoded = "SGVsbG8gV29ybGQh"
decoded_bytes = base64.b64decode(encoded)
decoded_text = decoded_bytes.decode('utf-8')
print(decoded_text)  # Output: Hello World!

# URL-safe Base64 decoding
url_safe_encoded = "SGVsbG8gV29ybGQh"
decoded_bytes = base64.urlsafe_b64decode(url_safe_encoded)
decoded_text = decoded_bytes.decode('utf-8')

PHP

<?php
// Decode Base64 to text
$encoded = "SGVsbG8gV29ybGQh";
$decoded = base64_decode($encoded);
echo $decoded;  // Output: Hello World!

// If handling binary data
$binary_data = base64_decode($encoded, true);
?>

Java

import java.util.Base64;

public class Base64Example {
    public static void main(String[] args) {
        // Decode Base64 to text
        String encoded = "SGVsbG8gV29ybGQh";
        byte[] decodedBytes = Base64.getDecoder().decode(encoded);
        String decodedText = new String(decodedBytes);
        System.out.println(decodedText);  // Output: Hello World!
        
        // URL-safe Base64 decoding
        String urlSafeEncoded = "SGVsbG8gV29ybGQh";
        byte[] urlDecodedBytes = Base64.getUrlDecoder().decode(urlSafeEncoded);
        String urlDecodedText = new String(urlDecodedBytes);
    }
}
Need to decode Base64 quickly?
Try our free online tool - no coding required! It's fast, secure, and private.
Use Our Decoder

Common Issues and Troubleshooting

When converting Base64 to text, you might encounter these common issues:

Invalid Base64 Input

If your Base64 string contains characters outside the Base64 alphabet (A-Z, a-z, 0-9, +, /, =), you'll get decoding errors. Check for:

  • Accidental whitespace or newline characters
  • Special characters that aren't part of Base64
  • Truncated strings (incomplete Base64)

Padding Issues

Base64 strings should be padded with '=' characters to make their length a multiple of 4. Some implementations might omit padding or add incorrect padding, causing decoding errors.

URL-Safe vs. Standard Base64

If you're trying to decode a URL-safe Base64 string (using '-' and '_' instead of '+' and '/') with a standard decoder, you'll get incorrect results. Make sure you're using the right decoding mode.

Encoding Mismatch

If the decoded output looks like gibberish, there might be an encoding mismatch. The original data might have been in UTF-8, ISO-8859-1, or another character encoding that doesn't match your decoder's expected output encoding.

Troubleshooting Tip

If you're getting decoding errors, try cleaning up your Base64 string by removing any whitespace, validating the length (it should be a multiple of 4 if padded), and ensuring all characters are valid Base64 characters.

Practical Examples of Base64 Decoding

Decoding a JWT Token

JSON Web Tokens (JWT) consist of three Base64Url-encoded parts separated by dots. Here's how to decode the payload:

JWT Token (simplified):
header.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.signature
Decoded Payload:
{"sub":"1234567890","name":"John Doe","iat":1516239022}

Decoding an Email Attachment

Email attachments in MIME format use Base64 encoding. Here's a simplified example:

MIME Content (excerpt):
Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 SGVsbG8sIHRoaXMgaXMgYSBzYW1wbGUgYXR0YWNobWVudC4=
Decoded Content:
Hello, this is a sample attachment.

Decoding a Data URI

Data URIs embed files directly in HTML/CSS using Base64 encoding:

Data URI (simplified):
data:text/plain;base64,SGVsbG8gV29ybGQh
Decoded Content:
Hello World!

Frequently Asked Questions

Is Base64 encoding a form of encryption?

No, Base64 is not encryption. It's merely an encoding scheme that converts binary data to ASCII text. It doesn't provide any security or confidentiality, as anyone can decode Base64 without a key. It's designed for data transport, not security.

Can all types of data be Base64 decoded to text?

Not all Base64-encoded data will decode to readable text. If the original data was binary (like an image or PDF), decoding it to text will result in unreadable characters. Base64 can encode any binary data, but only data that was originally text will decode back to readable text.

Why does my decoded Base64 sometimes contain strange characters?

If your decoded output contains strange or unexpected characters, it might be because:

  • The original data wasn't text but some other binary format
  • There's an encoding mismatch (e.g., the data was UTF-16 but you're interpreting it as UTF-8)
  • The Base64 string was corrupted or incomplete
Is there a size limit for Base64 decoding?

Theoretically, there's no fixed limit to how large a Base64 string can be decoded. However, practical limitations like memory constraints, browser limitations, or timeout issues might occur with extremely large strings. Our online tool is optimized to handle reasonable amounts of data efficiently.

How can I tell if a string is Base64 encoded?

Base64 strings have these characteristics:

  • They contain only characters from the Base64 alphabet (A-Z, a-z, 0-9, +, /, =)
  • Their length is a multiple of 4 (when properly padded)
  • Padding characters (=) only appear at the end and there are at most 2 of them

However, these checks aren't foolproof, as some valid strings might coincidentally match these patterns without being Base64.

Ready to convert Base64 to text?
Our free decoder provides instant results with complete privacy.
Try Our Decoder