DevKits

Base64 Encoder & Decoder

Encode and decode Base64 strings online. Supports UTF-8 text and URL-safe Base64. All processing runs locally in your browser.

Last updated:

15 chars

Type or paste any text or file above to encode it to Base64, or paste Base64 to decode it back. Runs entirely in your browser — no upload.

What is Base64?

Base64 is a binary-to-text encoding scheme that represents raw bytes using 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It's the standard way to embed binary data — images, keys, certificates, payloads — inside text-only contexts like JSON, XML, HTTP headers, and email (MIME).

How to Base64 encode or decode

  1. 1Choose Encode or Decode at the top of the tool.
  2. 2Paste your text (for encode) or Base64 string (for decode) into the input area.
  3. 3The result appears instantly on the right — no button click required.
  4. 4Toggle URL-safe mode if the output will be placed in a URL or filename (replaces +/ with -_).
  5. 5Click Copy to grab the result.

Use Cases

Embed small images in CSS or HTML

Inline a favicon or icon as a data URL (`url(data:image/png;base64,...)`) to save a network round-trip.

Send binary data in JSON APIs

JSON has no native binary type. File uploads via REST are commonly Base64-encoded strings inside a JSON field.

HTTP Basic Auth

The `Authorization: Basic ...` header is literally `base64(username:password)`. Decode any Basic header here to inspect it.

Store SSH keys and certificates

PEM-formatted keys and certs are Base64-encoded DER, wrapped in `-----BEGIN X-----` markers.

Code Examples

Base64 in the browser

// Encode
const encoded = btoa("hello");
// Decode
const decoded = atob(encoded);

Base64 UTF-8 safe

// btoa/atob only handle Latin1. For UTF-8:
const encoded = btoa(unescape(encodeURIComponent("你好")));
const decoded = decodeURIComponent(escape(atob(encoded)));

Base64 in Python

import base64
b = base64.b64encode(b"hello").decode()
plain = base64.b64decode(b).decode()

Base64 in Go

import "encoding/base64"

encoded := base64.StdEncoding.EncodeToString([]byte("hello"))
decoded, _ := base64.StdEncoding.DecodeString(encoded)

Base64 from the shell

# macOS/Linux
echo -n "hello" | base64        # encode
echo "aGVsbG8=" | base64 -d       # decode

Key Concepts

URL-safe Base64
A variant that replaces `+` with `-` and `/` with `_` so the result is safe in URLs, file names, and JWT tokens without further percent-encoding.
Base64URL
Same as URL-safe Base64, additionally omitting the `=` padding. Used inside JWTs (header, payload, and signature).
MIME Base64
The email variant: same alphabet as standard Base64, but wraps output at 76 characters per line.
Padding (=)
Base64 output length must be a multiple of 4. Missing bytes at the end are padded with `=`. Some parsers accept unpadded input — some don't.

Tips & Best Practices

  • Base64 encoding grows the payload by ~33%. For images larger than ~10 KB, HTTP-link them instead of inlining.
  • Base64 is encoding, not encryption. Anything you Base64 can be trivially decoded — never use it to 'hide' secrets.
  • When decoding fails, check for line breaks (`\n`) or spaces in the input — some parsers reject them, some accept them.
  • For URL-safe or JWT contexts, remember to also strip `=` padding — Base64URL is not the same as standard Base64.

Frequently Asked Questions

What is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string using 64 printable characters. It is commonly used to embed images in HTML/CSS or to transmit binary data over text-based protocols.

What is URL-safe Base64?

URL-safe Base64 replaces the + and / characters with - and _ so that the encoded string can be safely used in URLs and file names without additional escaping.

Related Tools