Encode text for use in URLs (percent encoding)
Encode text for URLs instantly with our free online URL encoder tool. This encoder helps web developers and API users convert special characters into percent-encoded format for safe transmission in URLs and query strings. Simply paste your text and get the URL-encoded output in real-time.
URL encoding converts characters into a format that can be transmitted over the Internet. Special characters are replaced with a percent sign (%) followed by two hexadecimal digits.
URL encoding (percent encoding) converts special characters into a format safe for URLs. Characters like spaces, &, =, and non-ASCII characters are replaced with % followed by their hexadecimal byte values. This is essential for query parameters, form submissions, and any data passed via URLs.
The encoder identifies characters that aren't URL-safe (letters, digits, -_.~) and converts each byte to %XX format where XX is the hexadecimal value. Spaces can become %20 or + depending on context. UTF-8 strings may produce multiple %XX sequences per character (e.g., € becomes %E2%82%AC).
RFC 3986 defines unreserved characters (A-Z, a-z, 0-9, -_.~) that don't need encoding. Reserved characters (:/?#[]@!$&'()*+,;=) have special URL meanings and must be encoded when used as data. The application/x-www-form-urlencoded format (HTML forms) additionally encodes spaces as + and handles special cases for form data.
Encode values in URL query strings to handle special characters.
?search=hello world becomes ?search=hello%20worldBrowser forms encode data before sending as POST body or GET query.
Encode user input before including in API URLs.
Safely include file names with spaces or special characters in download links.
Properly encode redirect URIs and callback URLs.
// Encode query parameter value
const encoded = encodeURIComponent('hello world & goodbye');
// Result: "hello%20world%20%26%20goodbye"
// Build URL with parameters
const params = new URLSearchParams({
name: 'John Doe',
city: 'New York'
});
const url = 'https://api.example.com/search?' + params.toString();
// Automatically encodes: ?name=John+Doe&city=New+York
// Don't double encode!
const alreadyEncoded = 'hello%20world';
// WRONG: encodeURIComponent(alreadyEncoded) = "hello%2520world"Use URLSearchParams for building query strings - it handles encoding automatically.
from urllib.parse import urlencode, quote, quote_plus
# Encode single value
encoded = quote('hello world') # hello%20world
encoded = quote_plus('hello world') # hello+world (form style)
# Build query string
params = urlencode({'name': 'John Doe', 'city': 'São Paulo'})
# name=John+Doe&city=S%C3%A3o+Paulo
# Encode path component
path = quote('my file.pdf', safe='')
# my%20file.pdfquote() uses %20 for spaces, quote_plus() uses + (form encoding). urlencode() handles entire dictionaries.
Use URL encoding whenever inserting variable data into URLs: query parameters, path segments, form submissions. Essential for preventing URL injection and handling special characters in web applications.
encodeURI encodes a complete URL, preserving :/?#[]@!$&'()*+,;= which have URL meanings. encodeURIComponent encodes everything except letters/digits/-_.~, making it suitable for query parameter values. Use encodeURIComponent for user input in parameters.