URL Encoder/Decoder
Encode URLs and query parameters or decode URL-encoded strings. Perfect for working with web APIs, query strings, and URL parameters.
Quick Examples
URL Encoding Tips
- Always encode query parameters and URL components
- Use Component Mode for query string values
- Spaces are encoded as %20 in URLs (or + in query strings)
- Reserved characters like ? & = must be encoded in values
- URL encoding is essential for API requests with parameters
- International characters require proper URL encoding
What is URL Encoding?
URL encoding (also called percent-encoding) is a method to encode special characters in URLs so they can be safely transmitted over the internet. URLs can only contain a limited set of ASCII characters, so any character outside this range must be encoded using the percent sign (%) followed by two hexadecimal digits.
For example, a space character becomes %20
, and an ampersand (&) becomes %26
. This encoding ensures that URLs are interpreted correctly by web servers and browsers, preventing conflicts with reserved URL characters and supporting international characters.
When to Use URL Encoding
Query Parameters: When passing values in URL query strings (e.g., ?search=hello world
becomes ?search=hello%20world
). This is the most common use case.
Path Segments: When including user-generated content or special characters in URL paths. For example, if a blog post title contains spaces or special characters.
Form Data: When submitting forms with application/x-www-form-urlencoded
content type, all data is URL-encoded.
API Integration: Most REST APIs require URL encoding for parameters that contain special characters, international text, or reserved characters.
Encoding Methods Explained
Component Mode (encodeURIComponent): This is the recommended method for encoding individual URL components like query parameter values. It encodes almost all special characters except - _ . ! ~ * ' ( )
. Use this when encoding values that will be part of a larger URL.
Full URL Mode (encodeURI): This method is designed for encoding complete URLs. It preserves URL structure characters like : / ? # [ ] @ ! $ & ' ( ) * + , ; =
while encoding other special characters. Use this for encoding entire URLs, not individual parameters.