%20
Encoding
URL Encoding FAQ — Percent Encoding, Query Strings & Special Characters
Answers to common questions about URL encoding (percent encoding), query string parameters, reserved characters, and how to handle Unicode in URLs.
Q1 What is URL encoding?
URL encoding (percent encoding) replaces unsafe characters in URLs with a
% followed by two hexadecimal digits. For example, a space becomes %20, & becomes %26. This ensures URLs contain only valid ASCII characters. Use the URL Encoder/Decoder to encode any string instantly.
Q2 Why do spaces become %20 in URLs?
Spaces are not valid in URLs according to RFC 3986. They must be encoded as
%20 (the hex value of the ASCII space character, 0x20). In HTML form submissions with application/x-www-form-urlencoded, spaces are encoded as + instead — both are valid in query strings, but %20 is correct in the URL path.
Q3 What characters need URL encoding?
Characters that must be encoded include: spaces,
< > # % { } | \ ^ ~ [ ] `, and non-ASCII characters (Unicode). Reserved characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) need encoding when used outside their reserved purpose. Unreserved characters (A-Z, a-z, 0-9, - _ . ~) never need encoding.
Q4 What is the difference between encodeURI and encodeURIComponent?
encodeURI() encodes a full URI but preserves reserved characters (: / ? # & =) so the URL structure stays intact. encodeURIComponent() encodes everything except unreserved characters, making it safe for query parameter values. Rule: use encodeURIComponent for values, encodeURI for complete URLs.
Q5 How do I URL-encode in Python?
Use
urllib.parse.quote(string) for path segments and urllib.parse.quote_plus(string) for query parameters (encodes spaces as +). To encode a full query string: urllib.parse.urlencode({"key": "value with spaces"}). To decode: urllib.parse.unquote(encoded).
Q6 How do I decode a URL?
Paste the encoded URL into the URL Decoder and click "Decode". In code: JavaScript —
decodeURIComponent(encoded); Python — urllib.parse.unquote(encoded); CLI — use an online tool or Python one-liner.
Q7 What is double URL encoding?
Double encoding happens when an already-encoded string gets encoded again:
%20 becomes %2520. This breaks URLs and is a common bug. It occurs when a framework auto-encodes values that you already encoded manually. Fix: encode only once, or decode before re-encoding.
Q8 How do I encode Unicode in URLs?
Unicode characters in URLs are first encoded to UTF-8 bytes, then each byte is percent-encoded. For example, the letter U+00FC becomes UTF-8 bytes
C3 BC, which are encoded as %C3%BC. Modern browsers display the Unicode character in the address bar but send the encoded form to the server.
Q9 What is the difference between %20 and + in URLs?
Both represent a space, but in different contexts.
%20 is the standard percent encoding for spaces (valid everywhere in a URL). + is only valid as a space in query strings when using application/x-www-form-urlencoded format (HTML form submissions). In the URL path, + is a literal plus sign, not a space.
Q10 How do I URL-encode in JavaScript?
For query parameter values:
encodeURIComponent('hello world & more'). For a complete URL: encodeURI('https://example.com/path with spaces'). For form data: use new URLSearchParams({key: 'value'}).toString() which handles encoding automatically.
Q11 Why do I need URL encoding for API calls?
Query parameters in API calls often contain special characters (
& = ? #) that have special meaning in URLs. Without encoding, q=rock&roll would be interpreted as two parameters (q=rock and roll=). URL encoding ensures q=rock%26roll is sent as a single value.
Q12 What is percent encoding in HTTP?
Percent encoding is the official name for URL encoding (defined in RFC 3986). Each byte that needs encoding is represented as
%HH where HH is the uppercase hexadecimal value. It ensures that all characters in a URI are valid ASCII and do not conflict with URI syntax delimiters.
Q13 How do I encode a URL in curl?
curl 7.18+ has
--data-urlencode for POST form data: curl --data-urlencode 'name=John Doe' https://api.example.com. For URL path encoding, use --url with percent-encoded values or let your shell handle it. curl does not auto-encode query parameters in GET requests.
Q14 Can I have special characters in URL paths?
Yes, but they must be percent-encoded. Forward slashes (
/) are path separators and should not be encoded in paths. Other special characters like spaces, ?, #, and non-ASCII characters must always be encoded. Modern web servers and frameworks handle encoding automatically in most cases.
Q15 What happens if I don't URL-encode parameters?
The URL may break or be misinterpreted. A
& in a value would be treated as a parameter separator, a # would truncate the URL at a fragment identifier, and non-ASCII characters may cause encoding errors or mojibake. Always encode user-supplied input in URLs.
Q16 How do I encode a full query string?
In JavaScript:
new URLSearchParams({key1: "val 1", key2: "val&2"}).toString(). In Python: urllib.parse.urlencode({"key1": "val 1", "key2": "val&2"}). These handle all encoding automatically. Or use the URL Encoder for quick manual encoding.
Q17 What is URL encoding in HTML forms?
When an HTML form is submitted with
method="GET" or POST with enctype="application/x-www-form-urlencoded", the browser automatically URL-encodes all form field values. Spaces become +, and special characters become %HH. This is the default encoding for HTML forms.
Q18 How long can a URL be?
The HTTP spec has no limit, but browsers and servers do. Chrome and Edge support URLs up to ~2 MB. Older IE versions had a 2,083 character limit. Most web servers default to 8-16 KB. Best practice: keep URLs under 2,000 characters for maximum compatibility. If you need more, use POST with a request body instead.
Q19 What is an Internationalized Resource Identifier (IRI)?
An IRI extends URIs to support Unicode characters directly (RFC 3987). Instead of percent-encoding every non-ASCII character, IRIs allow Unicode in the URL path. Browsers convert IRIs to URIs automatically for the network request. IRIs make URLs more human-readable for non-English content.
Q20 How do I URL-encode in PHP?
Use
urlencode($string) for query parameter values (encodes spaces as +) or rawurlencode($string) for path segments (encodes spaces as %20). To decode: urldecode($string) or rawurldecode($string). Use http_build_query($params) for full query strings.
Free Encoding Tools
All tools run in your browser — no signup, no data sent to servers.