Encode or decode URL strings for safe sharing.
The URL Encoder/Decoder converts text to and from percent-encoded URL format. URLs can only contain a limited set of 'safe' ASCII characters. Any other character (spaces, special symbols, non-ASCII letters, Unicode) must be percent-encoded: replaced with a % sign followed by two hexadecimal digits representing the character's byte value. For example, a space becomes %20, # becomes %23, and é becomes %C3%A9. Encoding is required for query string values, path segments with special characters, and data passed through HTTP requests.
encodeURI encodes a full URL — it leaves : / ? # & = intact because those are structural URL characters. encodeURIComponent encodes a URL component (like a query parameter value) — it encodes everything including & = and ?. Use encodeURIComponent for query string values.
Always encode user-provided values before appending to a URL. If a user searches for 'hello world & more', the query parameter must be ?q=hello%20world%20%26%20more or the & will break the URL structure.
Double-encoding happens when you encode an already-encoded string — %20 becomes %2520 (% becomes %25). The server decodes once and gets %20 instead of a space. Always decode before re-encoding.