URL Encoder / Decoder
Encode and decode URLs using encodeURI or encodeURIComponent.
Encodes a complete URI. Does NOT encode: ; / ? : @ & = + $ , #
Encoding comparison
https://example.com/path?name=John Doe&city=New Yorkhttps://example.com/path?name=John%20Doe&city=New%20Yorkhttps%3A%2F%2Fexample.com%2Fpath%3Fname%3DJohn%20Doe%26city%3DNew%20YorkUse encodeURI() for:
- • Full URLs with path and query
- • When you want to keep ? & = # intact
- • Encoding spaces and non-ASCII characters
Use encodeURIComponent() for:
- • Query parameter values
- • Form data
- • Any text that will be part of a URL
Common URL encodings
| Character | Encoded | Description |
|---|---|---|
| (space) | %20 | Space character |
| & | %26 | Ampersand |
| = | %3D | Equals sign |
| ? | %3F | Question mark |
| / | %2F | Forward slash |
| @ | %40 | At symbol |
Frequently Asked Questions
What's the difference between encodeURI and encodeURIComponent?
encodeURI() is for encoding complete URLs — it leaves characters like ; / ? : @ & = + $ , # intact. encodeURIComponent() encodes ALL special characters and is used for encoding individual URL parameters.
When should I use encodeURIComponent?
Use encodeURIComponent() when encoding query parameter values. For example, if a user enters "John & Jane" as a name, you need encodeURIComponent to properly encode the & character.
Why do spaces become %20?
Spaces are not allowed in URLs per RFC 3986. %20 is the percent-encoded representation of a space character (ASCII 32). Some systems also accept + for spaces, but %20 is more universally compatible.
What characters need to be encoded?
Any character outside the "unreserved" set (A-Z, a-z, 0-9, - _ . ~) should be percent-encoded. This includes spaces, non-ASCII characters, and reserved characters when used in data.
Is my data secure?
Yes. All encoding and decoding happens entirely in your browser using JavaScript. Your data is never sent to any server.