How to make URL safe Base64
- Type or paste your text into the left box. The example is a small JSON payload, the kind found in a JWT.
- URL-safe and Remove = padding are already ticked, so the output is ready for a JWT, a URL parameter or a file name.
- Untick Remove = padding if your system expects the
=signs, then Copy the result.
Standard Base64 vs Base64URL
| Standard Base64 | Base64URL | |
|---|---|---|
| Character 62 | + |
- |
| Character 63 | / |
_ |
| Padding | = required |
Usually omitted |
| Safe in URLs | No, needs escaping | Yes |
| Typical use | Email, data URIs, PEM | JWT, OAuth PKCE, URL tokens |
Example: the bytes FB FF encode to +/8= in standard Base64 and to -_8 in Base64URL without padding.
Where you meet Base64URL
- JSON Web Tokens. A JWT is three Base64URL strings joined by dots: header, payload and signature.
{"alg":"HS256","typ":"JWT"}becomeseyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9. - OAuth PKCE. The code challenge is the SHA-256 hash of the verifier, written in Base64URL without padding.
- Short IDs and file names. Random bytes written as Base64URL make compact IDs that never contain a
/.
Decoding Base64URL
To read a Base64URL string, paste it into the Base64 decoder. It accepts - and _ and restores the missing padding for you. For everyday Base64 output, use the main Base64 encoder.
Examples in URLs, file names and short IDs
The reason Base64URL exists becomes clear as soon as you put standard Base64 into a link. Take the bytes FB FF FE, which encode to +//+ in standard Base64. In a query string, + is read as a space and / can be taken as a path separator, so ?token=+//+ arrives at the server broken. To send it safely you would have to percent-encode it as %2B%2F%2F%2B. In Base64URL the same bytes are -__-, which needs no escaping at all.
Padding causes the same trouble. The = sign separates names from values in a query string, so a token like SGVsbG8= has to be written as SGVsbG8%3D inside a URL. That is why most URL-facing formats simply drop the padding: the decoder can work out how many bytes are missing from the length of the string.
File names have their own rule: / is forbidden on Linux and macOS, and Windows also rejects several other characters, so a standard Base64 name can fail to save. Base64URL uses only letters, digits, - and _, which are safe on every common file system. The same property makes it a good format for short IDs: 9 random bytes written in Base64URL give a 12-character ID such as Xk3_9qLw-2Tb that you can put in a URL, a file name or a database key without any conversion.