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
| Chunk | UTF-8 bytes (hex) | Base64 (std) | Base64URL | Change |
|---|
2 Β· Base64URL output
3 Β· Batch mode β one input per line
Worked examples β click to load
Classic anchor
BASICFive 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
ALPHABETStandard Base64 βfn5+β becomes βfn5-β
In: ~~~
Out: fn5-
Slash becomes underscore
ALPHABETStandard 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
JWTThe classic {"alg":"HS256"} header segment
In: {"alg":"HS256"}
Out: eyJhbGciOiJIUzI1NiJ9
Full pangram
BASIC43 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 62 | Position 63 | Padding | |
|---|---|---|---|
| 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.