Standard Base64 uses the characters +, /, and =. Those are unsafe in URLs and filenames, so a URL-safe variant swaps them out. It is defined in RFC 4648.
Standard vs URL-safe Base64
+becomes-(minus)/becomes_(underscore)=padding is often dropped entirely
Everything else (A–Z, a–z, 0–9) stays the same, so the two only differ by those characters.
Why + / = break URLs
In a URL query string a + is interpreted as a space, / is a path separator, and = separates keys from values. Left as-is, standard Base64 gets mangled or must be percent-encoded — which is exactly what URL-safe Base64 avoids.
Convert it online
Open the Base64 tool, enable the URL-safe variant option, then encode — the output uses - and _ instead of + and /.
URL-safe Base64 in code
// JavaScript — encode URL-safe
const urlSafe = btoa(str)
.replaceAll("+", "-")
.replaceAll("/", "_")
.replaceAll("=", "");
// JavaScript — decode URL-safe
const std = urlSafe.replaceAll("-", "+").replaceAll("_", "/");
const original = atob(std);# Python
import base64
enc = base64.urlsafe_b64encode(b"data").decode()
dec = base64.urlsafe_b64decode(enc)Where URL-safe Base64 is used
- JWTs — each part of a token is URL-safe Base64 without padding.
- URL query parameters and path segments.
- Filenames and cache keys, where
/is illegal.
Note: URL-safe Base64 is different from URL percent-encoding — Base64 re-encodes the data, while URL encoding only escapes reserved characters. Try the Base64 tool with the URL-safe option to see it.
