URL Encode & Decode - Online URL Encoder/Decoder
How to Use the URL Encoder and Decoder
Select Encode or Decode mode, paste your text or URL-encoded string, and see the converted result instantly. Encoding transforms special characters into their percent-encoded equivalents (for example, spaces become %20). Decoding reverses the process, turning percent-encoded strings back into readable text.
What Is URL Encoding (Percent Encoding)
URL encoding, formally known as percent-encoding, is defined by RFC 3986 as the standard way to represent special characters in URLs. Each unsafe character is replaced with a percent sign followed by two hexadecimal digits representing the character’s ASCII code.
URLs can only contain a specific set of unreserved characters: letters (A-Z, a-z), digits (0-9), hyphens, underscores, periods, and tildes. Every other character, including spaces, ampersands, and non-ASCII characters, must be percent-encoded to be included in a URL.
Characters That Must Be Encoded
| Character | Encoded | Why |
|---|---|---|
| Space | %20 | Not allowed in URLs |
| & | %26 | Separates query parameters |
| = | %3D | Separates key from value |
| ? | %3F | Starts query string |
| # | %23 | Starts fragment identifier |
| / | %2F | Path separator |
| + | %2B | May be interpreted as space |
| @ | %40 | Used in userinfo section |
When URL Encoding Is Required
URL encoding is essential whenever you construct URLs programmatically. The most common scenarios include building query strings with user input, constructing API request URLs, encoding redirect URLs within other URLs, and passing file paths or special characters in URL segments.
Failing to encode query parameters is a common source of bugs. For example, if a search query contains an ampersand, the unencoded & will be interpreted as a parameter separator, breaking the URL structure and causing incorrect data to reach the server.
URL Encoding in Different Programming Languages
Every language provides built-in functions for URL encoding, but the function names and behaviors differ:
| Language | Encode Function | Notes |
|---|---|---|
| JavaScript | encodeURIComponent() | Encodes individual values |
| Python | urllib.parse.quote() | Use quote_plus for form data |
| PHP | urlencode() | Encodes spaces as + |
| Java | URLEncoder.encode() | Requires charset parameter |
| Go | url.QueryEscape() | Encodes for query strings |
Double Encoding and Common Mistakes
Double encoding happens when an already-encoded string is encoded again, turning %20 into %2520. This is one of the most frequent URL-related bugs. It occurs when a framework or library automatically encodes URLs that you have already manually encoded. Always check whether your HTTP client applies encoding automatically before encoding values yourself.
Another common mistake is encoding the entire URL including the protocol and domain. Only the query parameter values and path segments containing special characters should be encoded. Use this tool to encode individual values, then assemble them into the full URL.
For encoding HTML special characters in web pages rather than URLs, use the HTML Entity Encoder. If you need to encode binary data for use in API payloads, the Base64 Encoder converts data to a text-safe format.
Related Tools
- Base64 Encoder/Decoder - Encode binary data as text for APIs
- HTML Entity Encoder - Encode special characters for HTML display
- Regex Tester - Test URL validation patterns
Frequently Asked Questions
What characters need to be URL encoded?
Characters with special meaning in URLs must be encoded, including spaces (%20), ampersands (%26), equals signs (%3D), question marks (%3F), hash symbols (%23), and forward slashes (%2F). Any non-ASCII characters like accented letters or emoji also require encoding.
What is the difference between encodeURI and encodeURIComponent?
encodeURI encodes a full URL but preserves characters that have structural meaning like ://?#. encodeURIComponent encodes everything except letters, digits, and a few safe characters, making it suitable for encoding individual query parameter values.
Why does a space become %20 or + in URLs?
In standard percent-encoding (RFC 3986), spaces are encoded as %20. In HTML form submissions using application/x-www-form-urlencoded, spaces are encoded as +. Both are valid in different contexts, but %20 is the more universal encoding.