URL Encoder / Decoder
Percent-encode a URL or query string, or decode it back to plain text.
About URL Encode / Decode
Percent-encodes or decodes a URL or query string, converting reserved and special characters to and from their %XX encoded form. Useful for constructing a query string parameter that itself contains special characters without breaking the surrounding URL structure, or decoding an encoded parameter from a log file. A surprisingly common source of bugs is double-encoding — encoding a string that's already encoded, which produces a URL that looks technically valid but decodes to the wrong value on the receiving end.
A space is encoded as either %20 or + depending on context — %20 is correct for a URL path, while + is specific to the application/x-www-form-urlencoded format used in query strings and form submissions; mixing them up produces a subtly wrong result.
Related Tools
Which characters get encoded
RFC 3986 allows only letters, digits and - . _ ~ to appear as-is everywhere in a URL. Reserved characters such as : / ? # [ ] @ ! $ & ' ( ) * + , ; = have special meaning and must be percent-encoded when they are part of the data. Any non-ASCII character is first converted to UTF-8 bytes and each byte becomes %XX: ş → %C5%9F, я → %D1%8F.
Component vs full URL
- Component (default,
encodeURIComponent): for one query value or path segment. Encodes/ ? & = #too. Use it for anything you insert into a URL. - Full URL (
encodeURI): for a whole URL that only contains a few spaces or non-ASCII characters. Keeps the URL's structure characters as they are.
Rule of thumb: encode each value separately with Component, then build the URL. Encoding a finished URL with Component breaks it; encoding values with Full URL leaves & and = unencoded and splits your parameter.
Gotchas
- Spaces:
%20is valid everywhere;+means space only in query strings and form data. The decoder here turns+into a space, so a literal plus sign must arrive as%2B. ! ' ( ) *are left as-is by JavaScript's encoder. OAuth 1.0 signatures and some AWS APIs require them encoded as%21 %27 %28 %29 %2A.- Double encoding:
%2520is an encoded%20. If you see it, something encoded the value twice. - Malformed sequences such as a lone
%or bytes that aren't valid UTF-8 produce a decode error.
Domain names are different
Non-ASCII domain names aren't percent-encoded; they use Punycode: bücher.de becomes xn--bcher-kva.de. Only the path and query use percent-encoding. Related: Base64 and text encoding detector.