Base64 encoder and decoder

Convert text to and from Base64 without leaving your browser. UTF-8 safe and privacy first.

How Base64 encoding works

Base64 is a transport encoding. It takes arbitrary bytes, groups them into 24 bit blocks, splits those blocks into four 6 bit chunks, and maps each chunk to an ASCII character from a 64 symbol alphabet. The output stays readable even when the original data is binary.

Encoding steps

  1. Read three bytes (24 bits) from the source input.
  2. Split the 24 bits into four groups of six bits.
  3. Map each six bit value to a printable character (A-Z, a-z, 0-9, +, /).
  4. Add = padding if the input length is not a multiple of three.

Key properties

  • No compression: the output grows by roughly 33%.
  • Reversible: decoding yields the original bytes exactly.
  • Alphabet variants: URL safe encoding swaps + for - and / for _.
  • Padding optional: many decoders cope without =, but the standard includes it.

Base64 vs other techniques

Encoding is often confused with hashing or encryption. Use the matrix below to pick the right approach for your workflow and avoid accidental data exposure.

Technique Purpose Reversible Security level Typical use
Base64 Transport binary data through text channels. Yes, decode restores the original bytes. None. Provides readability only. Data URIs, email attachments, JSON APIs.
Hashing Fingerprint data with fixed length digest. No. One-way function. Detects tampering when strong algorithms are used. File integrity, password storage with salts.
Encryption Protect confidentiality with a secret key. Yes, for whoever holds the key. Strong when modern ciphers and protocols are used. Secure messaging, storage, TLS, VPNs.

Common Base64 use cases

Use Base64 when a transport channel only accepts plain text but you need to deliver binary payloads intact.

MIME email

Mail transfer agents historically supported 7 bit data. Attachments ride along safely when you Base64 encode them before sending.

Data URLs

Embedding small images or fonts into CSS or HTML is easier with Base64 data URLs. Just keep assets tiny to avoid bloated bundles.

APIs and storage

Some APIs only accept JSON strings. Base64 lets you ship binary keys, certificates, or encrypted blobs without breaking the payload.

Quick question

Do you mostly encode text or binary files when using Base64?

JavaScript (browser)

function encodeBase64(text) {
  return btoa(unescape(encodeURIComponent(text)));
}

function decodeBase64(encoded) {
  return decodeURIComponent(escape(atob(encoded)));
}

console.log(encodeBase64('HashyTools'));
console.log(decodeBase64('SGFzaHlUb29scw=='));

Python (base64 module)

import base64

def encode_base64(text: str) -> str:
    return base64.b64encode(text.encode('utf-8')).decode('ascii')

def decode_base64(encoded: str) -> str:
    return base64.b64decode(encoded).decode('utf-8')

print(encode_base64('HashyTools'))
print(decode_base64('SGFzaHlUb29scw=='))

Base64 FAQ

How does Base64 encoding work?

Base64 groups bytes into 24 bit blocks, splits them into four chunks of 6 bits, and maps each chunk to a printable character from a 64 character alphabet, optionally adding = padding.

Is Base64 a secure way to hide data?

No. Base64 is reversible and offers no secrecy. Use proper encryption if you need confidentiality, and remember anyone can decode the text you publish.

Why do some Base64 strings end with equals signs?

Padding with = ensures the encoded output length is a multiple of four characters so any decoder can rebuild the original byte stream reliably.

When should I use URL safe Base64?

Use the URL safe alphabet (substituting - and _) when the encoded value lives inside URLs, filenames, or cookies where the original symbols might require escaping.

Does the tool send my data to a server?

No. All encoding and decoding happen locally in your browser so your secrets, tokens, and files remain private.