URL Encoder / Decoder
Encode or decode URL components and query strings instantly
50 characters
What Is URL Encoding (Percent-Encoding)?
URLs can only contain a limited set of ASCII characters. Any character outside that set β spaces, accented letters, symbols like &, =, #, and non-ASCII Unicode β must be percent-encoded before it can appear in a URL. Each such character is replaced by a % sign followed by two hexadecimal digits: space β %20, β¬ β %E2%82%AC, δΈ β %E4%B8%AD.
encodeURIComponent vs. encodeURI
JavaScript (and this tool) exposes two encoding functions:
-
encodeURIComponent β the safe default. Encodes everything except
AβZ aβz 0β9 - _ . ! ~ * ' ( ). Use this for individual query parameter names and values, path segments, and any user-provided data that becomes part of a URL. -
encodeURI (full URL mode) β encodes fewer characters. It leaves structural URL characters intact:
: / ? # @ ! $ & ' ( ) * + , ; =. Use this only when encoding an already-assembled full URL that has valid structure but may contain spaces or non-ASCII characters.
Rule of thumb: when inserting a variable into a URL, always use component encoding. When you have a complete URL that just needs unsafe characters cleaned up, use full URL encoding.
Common Characters and Their Encodings
- Space β
%20(or+in query strings) &β%26=β%3D+β%2B#β%23/β%2F?β%3F@β%40%β%25
Security: Always Encode User Input in URLs
Failing to URL-encode user-provided data before inserting it into a URL is a common source of security vulnerabilities. An unencoded & in a redirect parameter can hijack the request to a different endpoint. An unencoded # truncates the URL at the fragment separator. Use this tool to verify your application is encoding correctly, and always encode on the server side as well when constructing URLs from user input.