Base64 vs Base64URL

Why do three question marks encode as either Pz8/ or Pz8_? Compare the alphabets, check when the equals sign matters and see what happens to a plus sign in a query parameter.

Which characters give it away?

Standard Base64 uses + and /. Base64URL substitutes - and _. Each row shows hexadecimal bytes, standard Base64 and unpadded Base64URL. The letters in SGk are shared by both alphabets. Letters and digits alone cannot identify the alphabet the sender intended.

FB FF  →  +/8=  →  -_8
48 69  →  SGk=  →  SGk

Why the equals sign matters

Follow the receiving format’s rules for padding. A JWT segment omits the trailing equals sign. A decoder that expects standard padded Base64 may require it.

f    →  Zg==
fo   →  Zm8=
foo  →  Zm9v

Base64 encodes three bytes at a time. One remaining byte needs two padding signs in padded output, and two bytes need one. In an unpadded value, a length with remainder one when divided by four cannot represent complete bytes. Check for a missing character before adding padding.

Try both alphabets with text

In the text converter, encode three question marks using the standard alphabet, then repeat with URL-safe output. Only the last character changes. The byte comparison tool confirms that both outputs decode to the same three bytes.

???  →  Pz8/
???  →  Pz8_
HEX  →  3F 3F 3F

When a link changes the value

A form-style query parser reads a literal + as a space. If the receiving API expects standard Base64, use a URL parameter encoder so that + travels as %2B. If its protocol specifies Base64URL, use that alphabet and its padding rules. Test with a sample value before copying a real token.

?v=+/8=        →  " /8="
?v=%2B%2F8%3D  →  "+/8="

Read the first character inside each pair of quotes. In the first result it is a space. The second value still starts with a plus, so a Base64 decoder can recover the original bytes FB FF.

Official sources