URL Encode and Decode
Encode text for safe use in URLs or decode percent-encoded strings. Choose component encoding for query values or full URL encoding, all in your browser.
Encode text for safe use in URLs or decode percent-encoded strings. Choose component encoding for query values or full URL encoding, all in your browser.
URLs can only contain a limited set of characters. Anything else, such as spaces, ampersands or non-English letters, must be percent-encoded, for example a space becomes %20.
Use Component mode for a single query value (like encodeURIComponent) and Full URL mode to encode a whole address while keeping its structure (like encodeURI).
Input: a b&c=d/é Output: a%20b%26c%3Dd%2F%C3%A9
Percent-encoding, defined in RFC 3986, replaces an unsafe byte with a percent sign followed by two hexadecimal digits. Non-ASCII characters are first converted to UTF-8 bytes, and each byte is encoded, which is why the letter e with an acute accent becomes %C3%A9, two bytes. Unreserved characters, the letters, digits, hyphen, period, underscore and tilde, never need encoding. Reserved characters like slash, question mark and ampersand have meaning in a URL, so they are encoded only when used as data.
This is why two modes exist. JavaScript encodeURIComponent escapes nearly everything except unreserved characters and a few marks, making it right for a single value. encodeURI leaves structural characters such as colon, slash, question mark, ampersand, equals and hash intact, so it suits a complete address. Encoding a full URL in component mode breaks it, and encoding an already-encoded string twice turns %20 into %2520, a frequent bug.
Component mode also encodes characters like / ? & = # so a value is safe inside a query string. Full URL mode leaves those characters alone so the address keeps working.
%20 is the standard encoding for a space. A + means a space only in form-encoded query strings, which is why the decoder has a separate option.
A % that is not followed by two hex digits, or bytes that do not form valid UTF-8. Fix the text and try again.
No. Everything runs in your browser.
Not with percent-encoding. Internationalised domain names use a separate scheme called Punycode, while percent-encoding applies to the path, query and fragment parts of a URL.
Letters A to Z and a to z, digits 0 to 9, and the four marks hyphen, period, underscore and tilde are always safe in any part of a URL.