seo.base64_decode.how_desc
- seo.base64_decode.how_step1
- seo.base64_decode.how_step2
- seo.base64_decode.how_step3
- seo.base64_decode.how_step4
seo.base64_decode.how_example
Decode Base64 encoded strings back to original text or data.
Base64 decoding is the reverse process of Base64 encoding. It converts Base64 encoded ASCII text back into its original binary or text format. This decoder tool helps you quickly decode Base64 strings without any programming knowledge.
seo.base64_decode.how_desc
seo.base64_decode.how_example
Base64 decoding reverses the mathematical transformation that encoding performs. While encoding converts every 3 bytes into 4 characters, decoding takes every 4 Base64 characters and converts them back to 3 bytes. The decoder interprets each character according to the Base64 alphabet (A-Z = 0-25, a-z = 26-51, 0-9 = 52-61, + = 62, / = 63), converts them to 6-bit values, concatenates them into 24-bit blocks, and splits those back into the original 8-bit bytes. Padding characters (=) indicate that the original data length wasn't a multiple of 3, allowing the decoder to properly truncate the output.
Base64 decoding is reversible and provides no security. Anyone can decode Base64 strings. Treat decoded content as untrusted unless verified. Learn about encoding security
Most programming languages provide built-in functions for Base64 decoding. Here are examples with proper error handling:
// Basic decoding
$decoded = base64_decode($encoded);
// Decoding with strict mode (validates input)
$decoded = base64_decode($encoded, true);
if ($decoded === false) {
// Invalid Base64 string
throw new Exception("Invalid Base64");
}
// Decoding to UTF-8 string
$text = base64_decode($encoded, true);
if (!mb_check_encoding($text, 'UTF-8')) {
// Not valid UTF-8
}
// Browser (atob for ASCII only)
try {
const decoded = atob(encoded);
} catch (e) {
console.error("Invalid Base64:", e);
}
// Browser with UTF-8 support
function base64Decode(str) {
try {
return decodeURIComponent(escape(atob(str)));
} catch (e) {
throw new Error("Invalid Base64 or UTF-8");
}
}
import base64
# Decode to bytes
try:
decoded_bytes = base64.b64decode(encoded)
decoded_text = decoded_bytes.decode('utf-8')
except Exception as e:
print(f"Decoding failed: {e}")
# Validate Base64 before decoding
try:
decoded = base64.b64decode(encoded, validate=True)
except base64.binascii.Error:
print("Invalid Base64 string")
import (
"encoding/base64"
"fmt"
)
// Standard Base64 decoding
decoded, err := base64.StdEncoding.DecodeString(encoded)
if err != nil {
fmt.Println("Decoding error:", err)
return
}
// URL-safe Base64 decoding (for JWT)
decoded, err := base64.URLEncoding.DecodeString(encoded)
if err != nil {
fmt.Println("Decoding error:", err)
}
import java.util.Base64;
import java.nio.charset.StandardCharsets;
// Basic decoding
try {
byte[] decodedBytes = Base64.getDecoder().decode(encoded);
String decoded = new String(decodedBytes, StandardCharsets.UTF_8);
} catch (IllegalArgumentException e) {
System.err.println("Invalid Base64: " + e.getMessage());
}
// URL-safe decoding
byte[] decoded = Base64.getUrlDecoder().decode(encoded);
require 'base64'
# Basic decoding
begin
decoded = Base64.decode64(encoded)
rescue ArgumentError => e
puts "Invalid Base64: #{e.message}"
end
# Strict decoding (validates input)
decoded = Base64.strict_decode64(encoded)
# URL-safe decoding
decoded = Base64.urlsafe_decode64(encoded)
using System;
using System.Text;
// Basic decoding
try
{
byte[] bytes = Convert.FromBase64String(encoded);
string decoded = Encoding.UTF8.GetString(bytes);
}
catch (FormatException ex)
{
Console.WriteLine($"Invalid Base64: {ex.Message}");
}
Need to encode data to Base64? Use our Base64 Encoder to convert text or binary data to Base64 format.
Decoding JWT tokens? Our JWT Decoder automatically decodes all three sections and displays claims in a readable format.
Working with URL-encoded data? Try our URL Decoder to decode percent-encoded strings.