What is URL encoding?
URL encoding (percent-encoding) represents characters outside the unreserved set as a percent sign followed by two hexadecimal digits, for example %20 for a space. It keeps URLs, query strings, and form submissions safe when characters would otherwise break parsing or conflict with reserved delimiters like ?, &, and #.
Browsers and HTTP clients apply encoding automatically in many cases, but developers still need encoders when building links by hand, debugging APIs, or comparing client versus server behavior.
How to use this tool
- Choose encodeURIComponent for values (query parameters, path segments in APIs) or encodeURI when preserving URL structure matters.
- Type or paste text in the Decoded pane and click Encode, or paste an encoded string in the Percent-encoded pane and click Decode.
- Use Swap to exchange panes when iterating between plain and encoded forms.
- Enable Auto-encode on paste to update the encoded pane immediately when you paste into decoded text.
- Copy either side with the per-pane Copy buttons; character counts help compare lengths before and after encoding.
Common use cases
- Query parameters: Encode names and values that contain spaces, slashes, or unicode before appending them to a URL.
- OAuth and redirects: Inspect redirect URIs and state parameters where encoding mistakes cause “invalid_request” errors.
- Deep links and analytics: Verify campaign URLs and deep-link payloads match what servers expect after decoding.
- Debugging: Compare raw versus encoded representations when logs show percent-encoded values.
Tips for correct encoding
Always decode with the same family of functions used to encode: pairing encodeURIComponent with decodeURIComponent, and encodeURI with decodeURI. Mixing modes on strings that include reserved characters often yields double-encoding or decode errors.
For international text, JavaScript encodes UTF-8 bytes as percent sequences. If you see unexpected sequences, confirm the source text is valid Unicode and that no intermediate layer has already encoded the string twice.