🔗 URL Encoder/Decoder
Encode or decode URLs instantly as you type.
Why URL Encoding Exists and When You Need It
URLs can only be sent over the Internet using the ASCII character set. However, URLs frequently need to contain characters outside this set, such as spaces, accented letters, Chinese characters, or symbols like &, =, and #. URL encoding, also known as percent-encoding, solves this problem by replacing unsafe characters with a percent sign followed by two hexadecimal digits representing the character's ASCII or UTF-8 byte value. For example, a space becomes %20, an ampersand becomes %26, and the plus sign becomes %2B.
Reserved Characters and Why They Matter
The URL specification (RFC 3986) defines a set of reserved characters that have special meaning in URLs: :, /, ?, #, [, ], @, !, $, &, ', (, ), *, +, ,, ;, and =. When these characters appear as data (for example, in a search query rather than as URL structure), they must be percent-encoded to avoid ambiguity. Failing to encode them can cause broken links, incorrect routing, or security vulnerabilities such as URL injection attacks.
Common Use Cases for URL Encoding
Query parameters are the most common scenario. When you submit a search form, the browser automatically encodes your query so that spaces and special characters are transmitted correctly. API development requires encoding when passing user-generated content in URLs, such as filenames, addresses, or non-English text. Tracking links in email marketing campaigns often encode destination URLs inside redirect parameters to ensure the full target URL is preserved. OAuth and authentication flows rely on precise URL encoding when passing redirect URIs and tokens.
Encoding vs. Decoding
Encoding converts human-readable text into a URL-safe format, while decoding reverses the process. JavaScript provides encodeURIComponent() for encoding individual URL components and decodeURIComponent() for decoding them. The related encodeURI() function encodes a full URL but preserves characters like /, :, and ? that are part of the URL structure. Choosing the wrong function is a common bug: use encodeURIComponent for parameter values and encodeURI for complete URLs.