Every URL you type into a browser looks simple, but the underlying spec is strict about which characters are allowed and where. Spaces, ampersands, equals signs, hash symbols, and dozens of other characters have special meaning in URLs — or are simply forbidden. When you need to include those characters in a query string, a path segment, or an API parameter, URL encoding converts them into a safe percent-encoded format that any server and browser will parse correctly. The URL Encoder/Decoder on WebSurfTools handles this conversion instantly, in both directions.
What Is URL Encoding (Percent-Encoding)?
URL encoding — formally called percent-encoding — replaces characters that aren't allowed in URLs with a % followed by the two-digit hexadecimal representation of the character's ASCII or UTF-8 code. A space becomes %20. An ampersand becomes %26. A forward slash becomes %2F. The result is a URL that looks more complex but is unambiguous for any HTTP client or server to parse.
The URL spec divides characters into three categories: unreserved characters (letters, digits, -, _, ., ~) that are always safe; reserved characters (/, ?, #, &, =) that have special meaning in URLs; and everything else, which must be percent-encoded. When you use a reserved character in a place where it should be treated as data (not a delimiter), it must be encoded.
When URL Encoding Is Needed
Query String Parameters
The most common case. Query strings pass data to a server after the ? in a URL. If your parameter value contains a & or =, the server will misparse it as a delimiter. A search for "cats & dogs" in a query string must be encoded as q=cats%20%26%20dogs — otherwise the server reads the & as the start of a new parameter.
API Requests
When building API requests programmatically, any dynamic value inserted into a URL — a user-supplied search term, a product name, a date string — must be URL-encoded before concatenation. Skipping this step is a common source of 400 Bad Request errors and, in some cases, a security vulnerability (URL injection). Most HTTP libraries handle this automatically, but when you're constructing raw requests or debugging, understanding the encoding is essential.
Web Scraping
When scraping websites, you'll often need to construct URLs that include search parameters, filters, or pagination. Sites that use non-ASCII characters in their URLs (Japanese, Arabic, Chinese characters in page titles or categories) encode those characters in URLs. Decoding a scraped URL with the tool immediately reveals what the original query or parameter value was.
How to Use the URL Encoder/Decoder
- Open URL Encoder/Decoder.
- To encode: paste a URL or URL component (a query parameter value, a path segment) into the input and click Encode. The output replaces special characters with percent sequences.
- To decode: paste a percent-encoded URL or string and click Decode. The human-readable version appears.
- Copy the result for use in your code, browser, or API client.
Real-World Example
A developer builds a search feature that generates URLs like /search?q=new york city restaurants&category=italian. In testing, the server only receives new as the search term because the space breaks the URL and the rest is discarded. The fix: encode the query parameter values before building the URL. The encoded version: /search?q=new%20york%20city%20restaurants&category=italian. The decoder also comes in handy when reading server logs — a logged URL like /search?q=sushi%20%26%20ramen%20in%20tokyo decodes to the original user query: "sushi & ramen in tokyo."
For related encoding tasks, the Base64 Encoder/Decoder handles binary-to-text encoding for API payloads, and the Regex Tester is useful when you need to extract or validate URL patterns from strings.
Common Percent-Encoded Characters Reference
- Space →
%20(or+in form submissions) - Ampersand
&→%26 - Equals
=→%3D - Plus
+→%2B - Slash
/→%2F - Hash
#→%23 - Question mark
?→%3F - At sign
@→%40
Frequently Asked Questions
What is the difference between encoding a full URL and encoding a URL component?
Full URL encoding preserves the structural characters (://, /, ?, =, &) because they're part of the URL structure. Component encoding (which is what you usually want for parameter values) encodes those characters too, because within a parameter value they're data, not structure. Most encoding tools let you choose which mode to use.
Why does a space sometimes encode as + instead of %20?
In HTML form submissions (application/x-www-form-urlencoded format), spaces are encoded as +. In modern URL encoding (RFC 3986), spaces encode as %20. The + for space convention is a legacy of older HTML form handling and is still widely used in query strings.
Do I need to encode the entire URL or just the parameters?
Typically only the parameter values need encoding — the URL structure itself (scheme, host, path separators) should not be encoded. If you encode the entire URL including https://, you'll break the URL structure. Encode individual parameter values before assembling the full URL.
Is URL encoding the same as HTML encoding?
No. HTML encoding (HTML entity encoding) converts characters like < to < for safe display in HTML. URL encoding converts characters to %XX sequences for safe inclusion in URLs. They serve different purposes and apply in different contexts.