Published January 2026 • 5 min read
Have you ever noticed URLs that contain strange sequences like %20 or %26? This is URL encoding — also called percent-encoding. It is a mechanism that allows special characters to be safely transmitted within a URL.
URLs can only be sent over the internet using a limited set of ASCII characters. Many characters — spaces, ampersands, equals signs, and others — have special meanings within a URL structure. For example, & separates query parameters, and = separates keys from values. If your data contains these characters, it must be encoded to avoid confusing the URL parser.
URL encoding replaces unsafe characters with a % sign followed by two hexadecimal digits representing the character's ASCII code. Here are common examples:
Suppose you want to pass a search query as a URL parameter:
// Unencoded (will break the URL) https://example.com/search?q=hello world&lang=en // Encoded (safe to transmit) https://example.com/search?q=hello%20world&lang=en
Most programming languages have built-in functions for this. In JavaScript, use encodeURIComponent() for query parameter values and encodeURI() for full URLs. In Python, use urllib.parse.quote().
You can encode or decode any URL string directly using the URL Encode / Decode tool on this site — no setup required.