What is URL Encoding?
URLs can only contain a limited set of characters (letters, numbers, -, _, ., ~). All other characters — spaces, &, =, ?, special symbols — must be encoded using percent-encoding. For example, a space becomes %20, and & becomes %26.
Common Characters and Their Encoded Values
- Space →
%20 &→%26=→%3D?→%3F/→%2F@→%40#→%23
When Do You Need URL Encoding?
- Building API query strings with user-provided data
- Passing URLs as parameters within other URLs
- Handling form data sent via GET requests
- Creating links with special characters in the path
How to Encode or Decode a URL Online
encodeURIComponent() for query string values and encodeURI() for full URLs. encodeURIComponent is stricter and encodes more characters.FAQ
Is %20 or + used for spaces in URLs?
Both are valid! %20 is the strict percent-encoding standard. + is used in application/x-www-form-urlencoded data (like HTML form submissions). In query strings both are acceptable, but %20 is more universally correct.
Does URL encoding affect SEO?
Unencoded characters in URLs can cause broken links or incorrect page loads. Always encode special characters in URLs to ensure they work correctly in all browsers and crawlers.