URL Encoder & Decoder
Encode special characters in URLs for safe transmission, or decode percent-encoded URLs back to their original form.
What is URL Encoding?
URL encoding, also known as percent-encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI) under certain circumstances. It converts characters that are not allowed in a URL into a format that can be safely transmitted over the Internet. In URL encoding, unsafe ASCII characters are replaced with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII code.
For example, a space character becomes %20, and a forward slash (/) becomes %2F. This encoding ensures that the URL is interpreted correctly by web servers and browsers, preventing issues such as broken links, incorrect routing, or security vulnerabilities.
How to Use This Tool
Type or paste a URL, query string, or any text into the input area. Use the three buttons to apply different encoding modes:
- Encode URL applies encodeURI(), which encodes a complete URI by preserving characters that are part of the URI syntax (like :, /, ?, and #) while encoding other special characters.
- Encode Component applies encodeURIComponent(), which encodes all special characters including URI syntax characters. Use this for encoding query string parameter values.
- Decode applies decodeURIComponent() to convert percent-encoded sequences back to their original characters.
The Copy Output button copies the result to your clipboard.
Why URL Encoding Matters
Without URL encoding, special characters in URLs can cause incorrect parsing by web servers. For instance, a query parameter containing an ampersand (&) would be interpreted as a separator between parameters rather than part of the value. Similarly, a hash (#) would be treated as the beginning of a fragment identifier. URL encoding prevents these misinterpretations by converting problematic characters into their percent-encoded equivalents.
URL encoding is also essential for internationalization. Characters outside the ASCII range, such as accented letters, CJK characters, or emoji, must be encoded to be transmitted over the web safely. The browser handles this automatically in most cases, but when constructing URLs programmatically or processing user input, proper encoding is critical to ensure compatibility across all systems.
encodeURI vs encodeURIComponent
These two JavaScript functions serve different purposes. encodeURI() is intended for encoding complete URIs. It preserves characters that have special meaning in URIs (A-Z, a-z, 0-9, ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) #). Use this when you have a full URL with an existing structure that you want to encode for safe transmission.
encodeURIComponent() is more aggressive and encodes all characters except A-Z, a-z, 0-9, - _ . ! ~ * ' ( ). Use this when you are constructing a query string parameter value or a path segment and want to ensure that no character in your value is misinterpreted. Failure to use encodeURIComponent on user-supplied data that goes into a URL is a common source of bugs and security issues.