URL Safe Base64

Encode text to Base64URL, the URL and file name safe variant used by JWTs. URL-safe and no-padding are already switched on below.

0 bytes
0 chars

Everything runs in your browser. Your text and files are never uploaded.

How to make URL safe Base64

  1. Type or paste your text into the left box. The example is a small JSON payload, the kind found in a JWT.
  2. URL-safe and Remove = padding are already ticked, so the output is ready for a JWT, a URL parameter or a file name.
  3. 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

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.

Frequently asked questions

What is URL safe Base64?

It is Base64 with two characters swapped: - instead of + and _ instead of /. Both of the original characters have special meanings in URLs and file paths; the replacements do not. It is defined in RFC 4648 as base64url.

Should I remove the = padding?

For JWTs, yes: the JWT standard uses base64url without padding. For other uses, check what the receiver expects. The = sign must be written as %3D in a URL query, so many APIs drop it.

Can I decode a JWT here?

You can decode each part separately. Split the token at the dots and paste the first or second part into the Base64 decoder to read the header or payload. The third part is a binary signature.

Is URL safe Base64 the same as URL encoding?

No. URL encoding (percent-encoding) escapes individual characters as %XX. URL safe Base64 turns any bytes into a short string that needs no escaping at all.