Base64 Encoder & Decoder

Decode Base64

About Base64

What is Base64 encoding?

RFC 4648 Base64 converts each three-byte block into four ASCII characters using A-Z, a-z, 0-9, +, and /. A final short block is completed with = padding, so arbitrary bytes can travel through text-only formats.

Why use Base64 encoding?

Use Base64 for MIME attachments, JSON fields, certificates, or Data URLs that must carry binary bytes as text. It adds roughly 33% size and provides no compression, encryption, or integrity check; this decoder expects the standard alphabet and valid padding.

Base64 in Bash

# Encoding
echo -n "Hello, World!" | base64
# Output: SGVsbG8sIFdvcmxkIQ==

# Decoding
echo "SGVsbG8sIFdvcmxkIQ==" | base64 -d
# Output: Hello, World!
			

Base64 in Javascript

// Encoding
let encoded = btoa("Hello, World!");
console.log(encoded);
// Output: SGVsbG8sIFdvcmxkIQ==

// Decoding
let decoded = atob("SGVsbG8sIFdvcmxkIQ==");
console.log(decoded);
// Output: Hello, World!

			

Base64 in Go

package main
import (
	"encoding/base64"
	"fmt"
)
func main() {
	// Encoding
	encoded := base64.StdEncoding.EncodeToString([]byte("Hello, World!"))
	fmt.Println(encoded)
	// Output: SGVsbG8sIFdvcmxkIQ==

	// Decoding
	decoded, _ := base64.StdEncoding.DecodeString("SGVsbG8sIFdvcmxkIQ==")
	fmt.Println(string(decoded))
	// Output: Hello, World!
}
			

Base64 in PHP

// Encoding
$encoded = base64_encode("Hello, World!");
echo $encoded ."\n";
// Output: SGVsbG8sIFdvcmxkIQ==

// Decoding
$decoded = base64_decode("SGVsbG8sIFdvcmxkIQ==");
echo $decoded . "\n";
// Output: Hello, World!