URL / Base64 encoder & decoder
Convert between URL-encoding, URL-decoding, Base64-encoding and Base64-decoding. Full UTF-8 and emoji support.
URL encoding
Base64
URL-safe Base64
URL encoding and Base64 — what each is for
They solve different problems and are frequently confused. URL encoding (percent-encoding) makes text safe to place inside a URL. Reserved characters — :, /, ?, &, =, # — carry structural meaning, so any of them appearing in data must be replaced by %XX sequences. A space becomes %20 in a path or + inside a form-encoded query.
The distinction between encodeURI and encodeURIComponent matters: the former keeps the URL structure intact and is for encoding a whole URL, the latter escapes everything reserved and is what you want for a single query parameter value. Using the wrong one is the usual cause of links that break only for certain inputs.
Base64 is unrelated to URLs: it represents arbitrary bytes using 64 printable characters, which lets binary data travel through text-only channels — JSON payloads, email, data URIs, basic authentication headers. It expands data by about 33%, and it is an encoding, not encryption; anyone can reverse it.
Standard Base64 uses + and /, both of which have special meaning in URLs. URL-safe Base64 substitutes - and _ and drops the = padding — that is the variant to use for tokens in query strings, JWTs and signed URLs.
Finally, encoding is not the same as hashing: encoding is reversible and preserves length roughly, hashing is one-way and fixed length. If a value needs to be secret, neither is the answer.
Recognising and combining the encodings
You can usually tell which encoding you are looking at before you touch it. Scattered %XX pairs mean percent-encoding — and a %25 in front of them (%2520) means the text was encoded twice, the most common URL bug, fixed by decoding one more time than you think and preventing it by encoding exactly once, at the moment the value goes into the URL. Long runs of letters, digits and +/ ending in = or == are standard Base64; the same shape using - and _ without padding is URL-safe Base64 — which is what every JWT segment is.
Inside percent-encoding there are two dialects that do not agree on spaces: query strings built the form way (application/x-www-form-urlencoded) turn a space into +, while paths and modern query encoding turn it into %20. A + decoded by the wrong half becomes a space that was never typed, and a %20 passed through form-decoding survives as literal garbage. If a search term arrives as visitor+station or visitor%20station when you expected a space, this mismatch is why.
The characters that never need escaping are the unreserved set: A–Z, a–z, 0–9, and - . _ ~. Everything else is encoded by context, and context matters: / is structural in a path but data inside a query value, where it must become %2F if the receiver is to tell the two apart. Non-ASCII text is encoded at the byte level — the character is converted to its UTF-8 bytes and each byte becomes %XX, which is why one accented letter costs six characters (%C3%A9 for é) and why mojibake like é happens: those two characters are the two bytes of a UTF-8 é, read back as if they were Latin-1.
Base64 turns up in places far from this page. Data URIs embed small images and fonts directly in CSS or HTML (the compressor page can produce them); the Basic authentication header is literally the string user:password in Base64 — which is why HTTPS, not the encoding, is what protects it; PEM certificates are DER bytes wrapped in Base64 between header lines; and every JWT is three URL-safe Base64 segments separated by dots (decode one with the JWT tool). The grouping explains the size: three bytes become four characters, so expect about 33% inflation, and padding characters appear whenever the input length is not a multiple of three.
Last confusion to retire: encoding is reversible and keyless, hashing is one-way (try the hash calculator), and encryption is reversible with a key. Base64 belongs only to the first bucket; a value that needs to stay secret never relies on the encoding alone. For putting pieces back together instead of taking them apart, the URL parser splits any link into its encoded components.
Two edge cases finish the picture. The form %uXXXX (a UTF-16 escape) is not part of any URL standard — it is a legacy of old JavaScript functions, and a receiver that does not understand it will keep the literal %u text; convert such input through a decoder that recognises it rather than hand-patching. And treat decoding as an input-validation step, not a cosmetic one: a value that decodes to ../, to a javascript: prefix or to a second URL only becomes dangerous after your code has unwrapped it once, which is why safe pipelines decode to a canonical form first, validate the result, and only then use it.
Finally, match the encoder to the context: encodeURI() leaves structural characters like /?# intact and is for whole links, while encodeURIComponent() escapes them too and is for single query values. Mixing them up either breaks the link apart or smuggles an extra parameter into the query string.
Frequently asked questions
When should I use URL encoding instead of Base64?
URL encoding (percent-encoding) is for making text safe inside a URL — in query parameter values especially. Base64 is for representing arbitrary bytes as text, for example embedding binary data in JSON or a data URI.
What is URL-safe Base64?
Standard Base64 uses + and /, both of which have special meaning in URLs. URL-safe Base64 replaces them with - and _ and drops the trailing = padding, so the result can be placed in a URL unchanged.
Is Base64 encryption?
No. Base64 is an encoding — it is reversible by anyone with no key. Never use it to protect data; use encryption for that.
How to encode or decode
- Pick a direction: Switch between encode and decode.
- Choose method and enter text: Select URL or Base64 and enter the text to process.
- Copy the output: View and copy the encoded or decoded string.