Base64URL Encoder & Decoder

The URL-safe Base64 variant used by JWTs, cookies and query parameters. It swaps the plus sign for a hyphen and the forward slash for an underscore, so the encoded value can travel inside a link without percent-encoding and without being mangled by a mail client.

Text to encode

Base64URL output


            
            

Ready — paste some input or load the sample.

100% Client-Side · Privacy First. This tool runs entirely inside your browser. Nothing you type is uploaded, logged or sent to a server — you can even use it offline.

Overview

Base64URL is the variant of Base64 that RFC 4648 defines for use in URLs, filenames and JWTs. It looks like ordinary Base64 except that two characters are swapped: the plus sign becomes a hyphen and the forward slash becomes an underscore. The alphabet is A-Z, a-z, 0-9, - and _, and the padding can optionally be dropped. That last detail is the reason the variant exists — JSON Web Tokens are built from dot-separated segments that are URL-safe by specification, so the encoder must not produce a character that a URL parser would treat as syntax. This tool converts between plain Base64 and Base64URL in both directions, so you can take a standard encoded value from one library and produce the token-safe form, or decode a JWT segment back into readable JSON. It also handles the common mistake of a decoder that accepts both alphabets while an encoder that only produces one of them.

How to use the base64url encoder & decoder

  1. 1Paste the Base64 or Base64URL string into the input panel.
  2. 2Choose the direction: encode plain text, or decode an existing token segment back into readable text.
  3. 3Read the output and compare the alphabet in the notes with your source to see whether the input used standard or URL-safe characters.
  4. 4Paste the result into the URL, the header or the JWT builder that needs it.
  5. 5When you are repairing a token, decode the header segment and the payload segment separately, because the signature is not readable data.
  6. 6Remember that the padding is optional in this variant, so a value that ends without equal signs is usually not broken.

Cheat sheet

The syntax you will use most, and what each part does.

PatternWhat it means
+ becomes - The plus sign in the standard alphabet is replaced by a hyphen in Base64URL.
/ becomes _ The forward slash is replaced by an underscore, which keeps path segments intact.
Padding can be omitted Most JWT libraries strip the = characters, and decoders accept the short form.
eyJhbGciOiJIUzI1NiJ9 A JWT header segment is Base64URL; decoding it yields the JSON {"alg":"HS256","typ":"JWT"}.
Three-byte groups The block size is the same as standard Base64, so the length overhead is identical.
Never mix alphabets A standard string containing + or / will not decode as Base64URL without a fallback.

Common mistakes

A standard Base64 value fails to decode.

It may contain + or /. Decode it as standard Base64 first, or let the tool fall back to the other alphabet automatically.

A JWT is rejected by the server.

Check that every segment uses the URL-safe alphabet, that padding is stripped consistently, and that no line breaks crept in during copy and paste.

The decoded output is unreadable.

The segment may be compressed or encrypted rather than plain JSON. The decoder falls back to raw bytes when it is not valid UTF-8 text.

Two different strings decode to the same bytes.

Padding is optional, so an encoded value with and without the trailing equals signs is the same payload. That is normal, not a bug.

Worked examples

A token segment

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9

The decoded JSON object with the algorithm and type claims, showing that the payload was Base64URL.

Text prepared for a URL

binary-ish data

An encoded value that contains only A-Z, a-z, 0-9, hyphen and underscore, so it needs no percent-encoding.

Frequently asked questions

What exactly is the difference from standard Base64?

Only two characters change: plus becomes a hyphen and forward slash becomes an underscore. The padding equal signs are optional in the URL-safe variant, because most query string parsers treat an equal sign as part of the value.

Does a JSON Web Token really use Base64URL?

Yes. RFC 7515 encodes the header and the payload with base64url and drops the padding, so a token is always three dot-separated parts with no equal signs in the first two.

Should I keep the trailing equals signs?

It depends on the consumer. JWTs and most URL parsers want them removed, while a strict Base64 decoder in a script may need them, so restore the padding to a multiple of four whenever a decoder complains about the length.

Is the value sent to a server when I decode a token?

No. The token is parsed in your browser with the built-in atob equivalent, so a production access token never reaches a third-party decoder and never appears in a server access log.

Why does decoding a standard Base64 string sometimes fail?

Because the two alphabets do not mix. A value that contains a plus sign or a forward slash has to be translated back before a URL-safe decoder will accept it, and vice versa a hyphen or an underscore in a standard decoder is invalid.

Can the same value decode to two different strings?

No, not in a correct implementation. The decode is a deterministic inverse of the encode, so a round trip returns exactly the bytes you started with, which is why the tool is useful for checking a value that was truncated in a log.

Is Base64URL encrypted?

No. It is a transport encoding that only changes the alphabet so the value survives URL, cookie and header rules. It provides no confidentiality, so never use it to hide a secret that a reader should not see.

Where else does the URL-safe alphabet show up?

In cookie values that must not contain separators, in Slack and GitHub webhook signatures, in OAuth PKCE code verifiers and challenges, and in any query parameter that carries binary data.

How do I convert a standard value into the URL-safe one?

Replace every plus sign with a hyphen and every forward slash with an underscore. The Base64URL decoder here accepts both alphabets, so you can paste a standard value and read it either way.

Does the length of the result change?

The length is the same as standard Base64 apart from the padding, because only the characters change and not the underlying bytes. Three bytes always become four characters.

When is the padding actually required?

Only when the consumer is a strict decoder that expects a length that is a multiple of four. A JWT, a cookie and a query parameter are all fine without it, and adding it back is easy when a decoder complains.