πŸ” DEVELOPER TOOL Β· 100% CLIENT-SIDE

String to Base64URL

Free online string to Base64URL encoder: convert any text to URL-safe Base64 (RFC 4648 Β§5) instantly. UTF-8 aware, optional padding, per-chunk byte mapping, and batch mode. One-way only β€” your text never leaves the browser.

1 Β· Your text & options

0 characters 0 UTF-8 bytes 0 output chars 0 padding dropped 0 +/β†’-_ swaps

2 Β· Base64URL output

Your Base64URL output will appear here…

3 Β· Batch mode β€” one input per line

Worked examples β€” click to load

Classic anchor

BASIC Five ASCII bytes, one padding char dropped In: hello Out: aGVsbG8

Padding stripped

PADDING β€œ?” encodes to β€œPw==”; both β€œ=” are dropped In: ? Out: Pw

Multi-byte UTF-8

UNICODE β€œΓ©β€ is 2 UTF-8 bytes (C3 A9) In: Γ© Out: w6k

Plus becomes minus

ALPHABET Standard Base64 β€œfn5+” becomes β€œfn5-” In: ~~~ Out: fn5-

Slash becomes underscore

ALPHABET Standard Base64 β€œPz8/” becomes β€œPz8_” In: ??? Out: Pz8_

Emoji (4-byte)

UNICODE πŸŽ‰ is 4 UTF-8 bytes; standard form β€œ8J+OiQ==” In: πŸŽ‰ Out: 8J-OiQ

JWT header

JWT The classic {"alg":"HS256"} header segment In: {"alg":"HS256"} Out: eyJhbGciOiJIUzI1NiJ9

Full pangram

BASIC 43 bytes: 14 full chunks plus a 1-byte tail In: The quick brown fox jumps over the lazy dog Out: VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw

How string to Base64URL encoding works

Encoding runs in three steps. 1. Your text is encoded to UTF-8 bytes β€” this is what makes β€œΓ©β€ two bytes (C3 A9) and πŸŽ‰ four bytes. 2. Every 3 bytes (24 bits) are split into four 6-bit groups, each mapped to one of 64 ASCII characters β€” classic Base64. 3. The RFC 4648 Β§5 alphabet swap: + β†’ -, / β†’ _, and trailing = padding is dropped. The mapping table above shows all three steps for your exact input, chunk by chunk.

Position 62Position 63Padding
Standard Base64 (RFC 4648 Β§4)+/=
Base64URL (RFC 4648 Β§5)-_none (stripped)

Developers reach for a text to Base64URL converter when building JWTs, OAuth PKCE challenges, signed URLs, and URL-embedded tokens β€” anywhere a standard Base64 string would need ugly percent-encoding. Everything on this page runs locally in your browser: no fetch, no XHR, no server, so secrets and tokens stay on your machine.

What this string to Base64URL tool covers

  • string to base64url encoder online, free
  • text to base64url converter, no signup
  • url safe base64 encode text instantly
  • base64 vs base64url difference (RFC 4648 Β§5)
  • remove base64 padding for URLs and JWTs
  • keep padding option for strict APIs
  • encode string to base64url javascript snippet
  • base64url encode python β€” urlsafe_b64encode
  • utf-8 text to base64url, emoji-safe
  • base64url encode emoji (4-byte sequences)
  • json to base64url for JWT header and payload
  • base64url filename-safe encoding
  • plus to minus, slash to underscore swap
  • per-chunk 3-byte to 4-char mapping table
  • batch encode β€” one input per line
  • 100% client-side, zero network requests

Frequently asked questions

What is the difference between Base64 and Base64URL?

Base64URL is the URL-safe variant defined in RFC 4648 section 5. It uses exactly the same 24-bit to 4-character math as standard Base64, but swaps two characters that are unsafe in URLs: β€œ+” becomes β€œ-” (hyphen) and β€œ/” becomes β€œ_” (underscore). It also drops the trailing β€œ=” padding. The result contains only letters, digits, β€œ-” and β€œ_”, so it can sit in a URL path, query string or filename untouched.

Why is the = padding removed in Base64URL?

The β€œ=” character already means β€œquery-parameter assignment” in URLs, so padded output like β€œaGVsbG8=” can be misread by servers and routers. The padding carries no information β€” a decoder can infer it from the string length (length mod 4 reveals exactly how many β€œ=” were dropped) β€” so RFC 4648 Β§5 allows omitting it. This tool strips padding by default; toggle β€œkeep padding” on only if an API you talk to explicitly requires it.

When should I use Base64URL instead of standard Base64?

Anywhere the encoded string travels inside a URL, filename or token: JWT (JSON Web Token) segments, OAuth state and PKCE code challenges, signed URL parameters, cache-busting filenames, and data embedded in QR-friendly links. If the value only ever lives in JSON bodies, headers or config files, standard Base64 is equally fine.

How does this tool handle Unicode text and emoji?

Text is first encoded to UTF-8 bytes β€” the same step every correct implementation performs β€” and those bytes are then Base64URL-encoded. β€œΓ©β€ becomes the two bytes C3 A9, which encode to β€œw6k”, and πŸŽ‰ becomes four bytes, which encode to β€œ8J-OiQ”. The byte-mapping table above shows this step for your exact input. Naive tools that skip UTF-8 and call btoa() directly corrupt every non-ASCII character.

Is Base64URL encryption? Will it protect my data?

No. Base64URL is an encoding, not encryption β€” it is trivially reversible by anyone and provides zero confidentiality. Never use it to β€œhide” passwords, tokens or personal data. It only changes how bytes look so they survive transport through URLs.

How do I encode a string to Base64URL in code?

JavaScript: btoa(String.fromCharCode(...new TextEncoder().encode(s))).replace(/\+/g, β€œ-”).replace(/\//g, β€œ_”).replace(/=+$/, β€œβ€). Python: base64.urlsafe_b64encode(s.encode()).rstrip(b”=”). PHP: rtrim(strtr(base64_encode($s), β€œ+/”, β€œ-_”), β€œ=”). All three do UTF-8, then base64, then the alphabet swap, then strip padding β€” exactly like this tool.

Why can’t I just put standard Base64 in a URL?

You can, but the URL layer will mangle or bloat it: β€œ+” means β€œspace” in query strings, β€œ/” starts a new path segment, and β€œ=” separates keys from values. Percent-encoding fixes that β€” β€œ+” becomes β€œ%2B” β€” but triples the size of every affected character. Base64URL avoids the problem entirely by never producing those characters in the first place.

Related tools

One-way tool β€” encoding only. This page converts string β†’ Base64URL and nothing else. To decode Base64URL back to text, or to compare standard vs URL-safe alphabets side by side, use our two-way Base64 URL Encoder & Decoder.

Free tool by NRTechStudio