Base64 Encode / Decode / Base64URL Encode

The encoding algorithm is identical; only the alphabet differs. Standard Base64 uses + and /, while Base64URL swaps them for - and _ and strips the trailing = padding. The two outputs differ in length by a few characters, and a standard decoder cannot read a Base64URL string directly.

Base64 Encode / DecodeBase64URL Encode
Characters 62 and 63+ and /- and _
Trailing = paddingPadded to a multiple of fourNever present
Inside a URL+ becomes a space, / becomes a path separatorSafe as-is
Typical consumersBinary fields in JSON, email encodingJWT header and payload, cookies
Encode & Crypto

Base64 Encode / Decode

Base64 represents binary data with 64 printable characters, so binary can travel through text-only protocols. Encode: encodes any data into strings of the 64 characters A-Z, a-z, 0-9, + and / Decode: restores the original data from a Base64 string URL-safe mode: replaces + with -, / with _, and drops the = padding

Encode & Crypto
Encode & Crypto

Base64URL Encode

Base64URL is the URL-safe variant of Base64, used by JWTs and other values that travel in a URL. Replace + with - Replace / with _ Drop the trailing = padding

Encode & Crypto

When to use Base64 Encode / Decode

  • The output goes into JSON, a database field or an email body, never through a URL.
  • The receiving service only understands standard Base64 or expects padding.
  • You are handing someone a string to run through atob() — the standard form is the compatible one.

When to use Base64URL Encode

  • The output goes into a URL query, a path segment or a cookie value.
  • You are working with JWT, whose three segments are specified as unpadded base64url.
  • Filenames are involved and a / must not be read as a directory separator.

Verdict

Decide by destination: URL, cookie or JWT takes the URL variant; everything else takes standard Base64. Match the decoder too — a standard decoder rejects base64url as invalid characters.

Other comparisons

All tools