What is Base64 Encoding? A Complete Guide

Published Jan 29, 2026 · 5 min read

What is Base64?

Base64 is a binary-to-text encoding scheme that converts binary data into a string of ASCII characters. It uses 64 different characters (A-Z, a-z, 0-9, +, /) to represent data, making it safe to transmit over text-based protocols.

The name "Base64" comes from the fact that it uses 64 unique characters to represent data. Each character represents 6 bits of the original data (2^6 = 64).

How Base64 Works

Base64 encoding works by:

  1. Taking 3 bytes (24 bits) of binary data
  2. Splitting them into 4 groups of 6 bits each
  3. Converting each 6-bit group to its corresponding Base64 character

If the input isn't divisible by 3 bytes, padding characters (=) are added to make the output length a multiple of 4.

Common Use Cases

Code Examples

JavaScript

// Encode
const encoded = btoa("Hello World");
// Result: "SGVsbG8gV29ybGQ="

// Decode
const decoded = atob("SGVsbG8gV29ybGQ=");
// Result: "Hello World"

Python

import base64

# Encode
encoded = base64.b64encode(b"Hello World")
# Result: b'SGVsbG8gV29ybGQ='

# Decode
decoded = base64.b64decode(encoded)
# Result: b'Hello World'

Try our free Base64 encoder/decoder tool

Open Base64 Tool →

Key Takeaways