What is URL encoding?
URL encoding (also called percent-encoding) converts characters that are not allowed or have special meaning in URLs into a safe format using a % sign followed by two hex digits. For example, a space becomes %20, a colon becomes %3A, and a slash becomes %2F. This ensures URLs remain valid across all browsers and servers.
When do you need to decode a URL?
When working with API responses, logs, or shared links you may encounter URLs like search?q=hello%20world%21. Decoding translates those percent-codes back into readable text — hello world!. This is essential for debugging, reading query parameters, or making sense of redirected URLs.
Decode vs encode
Decoding translates %XX escape sequences back into their original characters. Encoding does the reverse: it takes plain text and replaces special characters with their %XX equivalents so the string can be safely embedded in a URL. Use encoding when constructing URLs programmatically and decoding when reading them.
Common percent-encoded characters
Space: %20. Hash: %23. Ampersand: %26. Plus: %2B. Equals: %3D. Slash: %2F. Question mark: %3F. At sign: %40. Colon: %3A. Comma: %2C.