URL Encoder/Decoder
Encode and decode URLs for safe transmission in web applications and APIs
URL Encoder/Decoder
Encode and decode URLs for safe transmission in web applications and APIs
URL Encoder
Common Examples
π Component Encoding
π Full URI Encoding
π Form Encoding
About URL Encoding and Decoding
URL encoding (percent encoding) converts special characters in URLs to a safe format that can be transmitted over the internet. This process replaces unsafe characters with percent signs followed by hexadecimal values. URL decoding reverses this process. Our tool handles both operations for query parameters, path segments, and full URLs.
- Encode special characters for safe URL transmission
- Decode percent-encoded URLs back to readable text
- Handle query parameters and path components
- Support for international characters and Unicode
- Component-level and full URL encoding options
URL Encoding Rules
Reserved Characters
- Space: %20 or + (in query strings)
- & (ampersand): %26
- ? (question mark): %3F
- # (hash): %23
- = (equals): %3D
- + (plus): %2B
Safe Characters
- Letters: A-Z, a-z (unchanged)
- Numbers: 0-9 (unchanged)
- Hyphens: - (unchanged)
- Periods: . (unchanged)
- Underscores: _ (unchanged)
- Tildes: ~ (unchanged)
Advertisement
Frequently Asked Questions
When should I URL encode data?
URL encode data when passing it as query parameters, form data, or any part of a URL that might contain special characters. This includes user input, search queries, file names, and international text. Always encode before sending HTTP requests to prevent parsing errors.
What's the difference between component and full URL encoding?
Component encoding (encodeURIComponent) encodes all special characters including slashes and colons, making it safe for query parameters. Full URL encoding (encodeURI) preserves URL structure characters like slashes and colons, suitable for encoding complete URLs while maintaining their functionality.
Why do spaces become %20 or + in URLs?
Spaces become %20 in URL paths and components, and can become + in query string parameters (legacy behavior). Modern applications typically use %20 consistently. The + encoding is from HTML form submissions, but %20 is more universal and recommended.
Can I double-encode URLs?
Yes, but it's usually unintentional and causes problems. Double encoding happens when already-encoded data gets encoded again (e.g., %20 becomes %2520). Always check if data is already encoded before applying additional encoding to avoid this issue.
URL Encoding Examples
Common Encoding Scenarios:
Sponsored Content
Programming Implementation
JavaScript:
// Component encoding (for query parameters)
const component = "hello world & more!";
const encoded = encodeURIComponent(component);
console.log(encoded);
// "hello%20world%20%26%20more!"
const decoded = decodeURIComponent(encoded);
console.log(decoded);
// "hello world & more!"
// Full URI encoding (preserves structure)
const uri = "https://example.com/search?q=hello world";
const encodedURI = encodeURI(uri);
console.log(encodedURI);
// "https://example.com/search?q=hello%20world"
// Building query strings
function buildQuery(params) {
return Object.keys(params)
.map(key =>
encodeURIComponent(key) + '=' +
encodeURIComponent(params[key])
)
.join('&');
}
const params = { name: "John Doe", age: 30, city: "New York" };
console.log(buildQuery(params));
// "name=John%20Doe&age=30&city=New%20York"
Python:
import urllib.parse
# URL component encoding
component = "hello world & more!"
encoded = urllib.parse.quote(component)
print(encoded)
# "hello%20world%20%26%20more%21"
decoded = urllib.parse.unquote(encoded)
print(decoded)
# "hello world & more!"
# Query parameter encoding
params = {
'name': 'John Doe',
'age': '30',
'city': 'New York'
}
query_string = urllib.parse.urlencode(params)
print(query_string)
# "name=John+Doe&age=30&city=New+York"
# Parse and encode URLs
from urllib.parse import urlparse, urlunparse, quote
url = "https://example.com/path with spaces"
parsed = urlparse(url)
encoded_path = quote(parsed.path)
safe_url = urlunparse(parsed._replace(path=encoded_path))
print(safe_url)
# "https://example.com/path%20with%20spaces"
Character Encoding Reference
Common Symbols:
Punctuation:
Extended ASCII:
URL Encoding Best Practices
Encoding Guidelines:
Common Pitfalls:
Common Use Cases
- Form data transmission
- Search query parameters
- API endpoint construction
- File upload handling
- Social media sharing URLs
- Email link generation
- Analytics tracking parameters
- Internationalization support
Advertisement
