URL encode and decode
Percent-encode text for URLs and query strings, or decode %20-style strings back to text. Component and full-URL modes, in your browser.
How it works
URLs can only contain a limited set of characters. Percent-encoding replaces everything else with % and two hex digits per UTF-8 byte: a space becomes %20, é becomes %C3%A9.
Use component mode for a single query value or path segment: it also encodes & = ? / and #, which would otherwise change the meaning of the URL. Use full-URL mode to clean up a whole address while keeping its structure.
Questions
- Should a space be %20 or +?
- %20 works everywhere. + means a space only inside application/x-www-form-urlencoded query strings.
- Why did decoding fail?
- A % must be followed by two hex digits. A lone % or a truncated sequence such as %E2%82 cannot be decoded.
Do this in your code
The same job is one call to the APIStack API, from any language or as a tool for AI agents over MCP. The free plan includes it.
curl -X POST https://apistack.online/api/utilities/url-encoder/v1 \
-H "x-api-key: $APISTACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input":"https://example.com/path with spaces?q=a&b","operation":"encode","component":"full"}'