Encode or decode URLs and query strings. Convert special characters to percent-encoding and back. Supports full URL and component encoding.
URL Encoder / Decoder
Ad · 336x280
URL Encoding: Percent-Encoding Explained
URLs can only contain a limited set of safe characters. Special characters (spaces, #, &, =, +, non-ASCII letters) must be percent-encoded as %XX where XX is the hexadecimal ASCII code. A space becomes %20, & becomes %26, and non-ASCII characters like ü become %C3%BC.
encodeURIComponent vs encodeURI
encodeURIComponent: Encodes everything except: A–Z a–z 0–9 - _ . ! ~ * ' ( ). Use for individual query parameter values — it encodes / : @ & = + $ , # which must be escaped inside values
encodeURI: Leaves the URL structure intact — preserves / : @ & = + $ , # ? and only encodes spaces and non-ASCII. Use for full URL encoding.
Common Percent-Encoded Characters
Space → %20 (or + in form data)
& → %26
= → %3D
# → %23
+ → %2B
/ → %2F
? → %3F
Frequently Asked Questions
Encode when: (1) building a query string with dynamic values (always encode parameter values), (2) constructing a URL in JavaScript with user input, (3) passing a URL as a parameter inside another URL, (4) including special characters in a URL path. Never double-encode — if a string is already encoded, decode first then re-encode if needed.
Both represent a space in URLs, but in different contexts. %20 is the standard percent-encoding for a space anywhere in a URL (path, query, fragment). + for space is only valid in query strings (application/x-www-form-urlencoded format), used by HTML forms when submitted. The decodeURIComponent() function only handles %20; to handle + as space in form data, replace + with %20 first.
Unencoded special characters confuse URL parsers. A & in a URL value looks like a new parameter separator. A # looks like a fragment identifier. A space creates an invalid URL. Always encode user input before including it in a URL: JavaScript encodeURIComponent(value), Python urllib.parse.quote(value), PHP urlencode($value), Ruby ERB::Util.url_encode(value).
Python 3: from urllib.parse import unquote, unquote_plus. unquote('%20') returns ' ' (space from %20). unquote_plus('+') also returns ' ' (handles form-encoded +). For encoding: from urllib.parse import quote, quote_plus. quote('hello world') returns 'hello%20world'. For complete URL encoding/decoding with query params: urllib.parse.urlencode() and urllib.parse.parse_qs().