URL Encoder / Decoder
Encode special characters for use in URLs or decode percent-encoded strings back to readable text.
What Is URL Encoding?
URL encoding (also called percent encoding) is the process of replacing special characters in a URL with their percent-encoded equivalents. URLs can only contain a limited set of characters from the ASCII character set — letters, digits, and a few special characters like hyphens and underscores. Any other character (spaces, ampersands, non-English letters, emoji) must be encoded before it can be safely included in a URL.
For example, a space is encoded as %20, an ampersand (&) becomes %26, and the Japanese character あ becomes %E3%81%82. This encoding ensures that URLs are transmitted correctly across all systems without ambiguity or data corruption.
encodeURIComponent vs encodeURI
JavaScript provides two encoding functions that serve different purposes. encodeURIComponent() encodes everything except letters, digits, and the characters - _ . ! ~ * ' ( ). It's the right choice for encoding individual query parameter values, form data, or any fragment that will be inserted into a URL.
encodeURI() encodes a complete URL but preserves characters that are part of URL syntax — colons, slashes, question marks, hash signs, and ampersands. Use it when you have a full URL that just needs its special characters (like spaces in a path) encoded without breaking the URL structure.
Common Use Cases
You need URL encoding whenever you build URLs dynamically: constructing API requests with user-supplied search terms, building query strings for GET requests, creating links that contain special characters or non-Latin text, encoding file paths with spaces in URLs, and passing JSON or structured data as URL parameters. Decoding is needed when you receive percent-encoded URLs from APIs, logs, or analytics tools and want to read the original text.