URLs can only contain a specific set of characters. Letters, numbers and a handful of symbols like hyphens, underscores and periods are safe in URLs. Characters outside this set, including spaces, special characters, non-Latin letters, and symbols with special meaning in URL syntax, must be encoded before they can be included in a URL without causing problems. URL encoding replaces unsafe characters with a percent sign followed by the two-digit hexadecimal code for that character.
A space becomes %20 in URL encoding. An ampersand becomes %26. A French é becomes %C3%A9 because its Unicode representation requires two bytes in UTF-8 encoding. The process is systematic and reversible, which is why decoding is equally straightforward.
Why URL encoding exists
URLs were designed when the internet was primarily English-language and technical. The original specification reserved certain characters for specific purposes within URL syntax. The question mark separates the path from the query string. The ampersand separates query parameters. The hash marks the start of a fragment. The colon and slashes define the protocol and server components. Any character that has a reserved meaning in URL syntax must be encoded when it appears as data rather than as a structural element.
Consider a search query for the phrase fish and chips. If the URL passes this as a parameter without encoding, it becomes search?q=fish and chips. The space in the middle breaks the URL in most parsers. The encoded version is search?q=fish%20and%20chips, which unambiguously represents the three-word phrase as a single parameter value. Any URL parser that processes this correctly extracts fish and chips as the search term.
Internationalization extended the need for encoding further. Unicode characters that represent non-Latin scripts, accented letters and symbols outside the original ASCII set all require encoding in URLs. This is why URLs from Arabic, Chinese, Japanese and other non-Latin-script websites often appear as long sequences of percent-encoded characters when copied from the browser address bar, even though the browser displays them in human-readable form.
URL encoding versus HTML encoding
URL encoding and HTML encoding are different systems that are easy to confuse because they both exist to make characters safe in specific contexts. URL encoding uses percent signs and hexadecimal codes. HTML encoding uses named entities or numeric references. An ampersand in HTML is written as & or &. The same ampersand in a URL is written as %26.
The context determines which encoding to use. Data that will appear in a URL needs URL encoding. Content that will appear in HTML markup needs HTML encoding. Data in a URL that is embedded in HTML may need both applied in the correct order. Getting the encoding context wrong produces broken links or display errors that can be difficult to trace without understanding why the two encoding systems exist.
When you need to decode a URL
Reading a URL that contains encoded characters is the most common reason to decode. A URL shared from a search engine or a web application often contains encoded query parameters that are meaningful if read but incomprehensible as encoded strings. Decoding reveals the actual search terms, filter values or parameters that the URL encodes.
Debugging web applications frequently requires decoding URL parameters to verify that data is being passed correctly. An API call that is not working as expected may have an encoding error in one of its parameters. Decoding the full URL and examining each parameter value in readable form is often the fastest way to identify what is wrong.
Extracting data from server logs is another common use. Web server logs record the full URL of each request including encoded parameters. Analyzing log data to understand what users searched for, what products they viewed, or what errors occurred requires decoding the logged URLs to make them readable.
Common encoding mistakes
Double encoding happens when a value that is already encoded gets encoded again. The encoded %20 for a space contains a percent sign, and if the whole string is encoded again, the percent sign itself becomes %25, turning %20 into %2520. The result is a URL that, when decoded once, still contains an encoded value rather than the original text. This is a common source of bugs in web applications that process URL parameters through multiple functions.
Forgetting to encode special characters in query parameter values causes problems when those characters have meaning in URL syntax. An API key that contains an equals sign or a plus sign, a product name that contains an ampersand, or a user-submitted search term that contains special characters all need to be encoded before being included in a URL parameter.
Encoding characters that should not be encoded can also cause problems. The slash in a URL path segment has a specific meaning, and encoding it as %2F in some server configurations produces a different result than leaving it as a literal slash. Encoding only the data portions of a URL and leaving the structural characters unencoded is the correct approach.
- Open the URL Encode/Decode tool below.
- Paste the text or URL you want to encode or decode.
- Select whether to encode or decode.
- Copy the result.
Encode or decode URLs and query strings instantly.