Base64URL decode.
Paste URL-safe Base64 (with - and _), standard Base64, or a whole JWT.
Standard (RFC 4648 §4) uses + and / and pads with =. URL-safe (§5) uses - and _ and usually drops the padding. All other 62 characters are the same.
You get the decoded text, both forms of the string and the padding fixed. Everything runs in your browser.
Updated 9 November 2026
Base64URL (RFC 4648 §5) is Base64 with - instead of + and _ instead of /, usually without = padding. To decode it, swap those two characters back, add = until the length is a multiple of 4, then decode as normal Base64. The tool above does all three; the code below shows how in Python, JavaScript, the shell and PowerShell.
URL-safe to standard, and back.
How Base64URL decoding works
Base64URL changes only two of the 64 characters, so converting is mechanical:
- Replace
-with+and_with/. - Add
=until the length is a multiple of 4: two if the remainder is 2, one if it is 3. A remainder of 1 can't happen with valid input, so the string was cut off. - Decode the result with any standard Base64 decoder.
Going the other way, swap the characters back and strip the trailing =. Both directions are lossless: the bytes never change, only how they're written.
JWTs (RFC 7515) require Base64URL without padding for all three segments. That's why a plain Base64 decoder often rejects a JWT payload even though it looks like Base64.
Decode Base64URL in your language.
PythonFull Python guide →
import base64
def b64url_decode(s: str) -> bytes:
return base64.urlsafe_b64decode(s + "=" * (-len(s) % 4))
def b64url_encode(b: bytes) -> str:
return base64.urlsafe_b64encode(b).rstrip(b"=").decode("ascii")
JavaScriptFull JavaScript guide →
// Node.js: "base64url" handles the alphabet and missing padding
Buffer.from("eyJhbGciOiJIUzI1NiJ9", "base64url").toString("utf8");
// Browser
const std = s.replace(/-/g, "+").replace(/_/g, "/");
const bytes = Uint8Array.from(atob(std), c => c.charCodeAt(0)); // atob accepts missing padding
Linux / macOSFull Linux and macOS guide →
# GNU coreutils 8.31+ (needs padding)
echo '_-7d' | basenc --base64url -d
# Anywhere: translate, pad, decode
s=$(printf '%s' "$s" | tr '_-' '/+'); while [ $(( ${#s} % 4 )) -ne 0 ]; do s="$s="; done
printf '%s' "$s" | base64 --decode
PowerShellFull PowerShell guide →
$s = $s.Replace('-', '+').Replace('_', '/')
switch ($s.Length % 4) { 2 { $s += '==' } 3 { $s += '=' } }
[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($s))
About this tool.
Base64URL is the URL- and filename-safe variant of Base64 defined in RFC 4648 section 5. It replaces + with - and / with _, so the string can go in a URL or file name without escaping. Padding is usually left off.
Replace every - with + and every _ with /, then add = characters until the length is a multiple of 4. The result decodes with any standard Base64 decoder.
JWTs travel in URLs, HTTP headers and cookies, where + / and = can be altered or need escaping. RFC 7515 therefore specifies Base64URL with the trailing = removed.
Yes, if it contains none of + / - or _. Such a string decodes to the same bytes either way. The tool reports it as compatible with both.
No. Conversion and decoding run in JavaScript in your browser. Nothing is uploaded or stored.