The 30-second answer
Base64URL is Base64 with two characters swapped and the padding dropped. Everything else — the algorithm, the decoded bytes — is identical.
| Feature | Standard Base64 | Base64URL |
|---|---|---|
| Alphabet | A–Z a–z 0–9 + / | A–Z a–z 0–9 - _ |
| Padding | = added as needed | Usually omitted |
| Safe in URLs | No | Yes |
| Used in | MIME email, data URIs, PEM certificates | JWTs, OAuth tokens, filenames |
Why URLs break standard Base64
Three Base64 characters are URL-hostile: + means “space” inside query strings, / is a path separator, and = must be percent-encoded as %3D. Drop a standard Base64 string into a URL unescaped and it gets mangled. Base64URL (RFC 4648 §5) fixes this by substituting + → - and / → _, and typically omitting the = padding — the result can sit in a URL, filename or HTTP header verbatim.
Why JWT uses Base64URL
A JWT is three Base64URL segments joined by dots: header.payload.signature. Tokens travel in Authorization headers, URL query parameters and cookies — exactly the places standard Base64 breaks. That is why RFC 7515 (JWS) mandates unpadded Base64URL for all three segments. Decode the middle segment and you get the payload JSON with claims like exp. Try the JWT Decoder to inspect any token.
How to convert between them
It is two string replacements plus padding handling:
// Base64 -> Base64URL
function toBase64Url(b64) {
return b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
}
// Base64URL -> Base64 (re-add padding first)
function fromBase64Url(b64url) {
let b64 = b64url.replace(/-/g, '+').replace(/_/g, '/');
while (b64.length % 4) b64 += '=';
return b64;
}
How to tell which one you are looking at
- See
-or_in the string? It is Base64URL — almost certainly a JWT or OAuth token. - See
+,/or trailing=? It is standard Base64. - Nearly every JWT starts with
eyJ— that is just{"(the start of JSON) encoded; not a magic marker.
Common pitfall: atob() chokes on JWTs
JavaScript’s atob() only understands standard Base64. Feed it a JWT payload containing - or _ and it throws. Convert to standard Base64 (replacements + padding above) before decoding — or paste the token into the JWT Decoder, which handles it for you.
Honest note
Base64URL is not encryption — it is trivially reversible. Never use it to “hide” passwords or API keys; anyone can decode it in seconds. For secrets, use real encryption and HTTPS. Also note: the free Base64 Encoder tool on this site handles standard Base64 encode/decode; the live widget at the top of this page shows the URL-safe variant.
Frequently asked questions
What is the difference between Base64 and Base64URL?
Base64URL replaces + with - and / with _ and usually drops the = padding so output is safe in URLs, filenames and HTTP headers. The decoded bytes are identical — only two alphabet characters and padding differ.
Why does JWT use Base64URL instead of standard Base64?
JWTs travel in Authorization headers, URL query parameters and cookies, where +, / and = get misparsed or need escaping. RFC 7515 mandates unpadded Base64URL for all three JWT segments so a token can be used verbatim.
Can I decode Base64URL with a standard Base64 decoder?
Not directly — a standard decoder rejects - and _. Convert first: replace - with +, _ with /, then re-add = padding until the length is a multiple of 4.
Does Base64URL always drop the padding?
Usually. JWT (RFC 7515) forbids padding entirely, while general Base64URL (RFC 4648) allows it. Well-written decoders accept both padded and unpadded input.
How can I tell if a string is Base64URL?
Look for - or _ characters — standard Base64 never contains them. JWTs also typically start with eyJ, which is just the JSON opening {" encoded.
Is Base64URL a form of encryption?
No. It is an encoding, trivially reversible by anyone. Never use it to protect passwords, API keys or tokens — use real encryption and HTTPS.
Try it now
Type into the live converter above to see both encodings side by side — or open the full Base64 Encoder for decoding and file support.