URL Encoder & Decoder
Percent-encode strings for use in URLs and query parameters, or decode percent-encoded URLs back to readable text.
Awaiting input
Component vs full-URL encoding
Two operations exist in JavaScript:
encodeURIComponent()— encodes everything that isn't a letter, digit, or one of- _ . ! ~ * ' ( ). Use this for individual query parameter values.encodeURI()— leaves URL-reserved characters like:,/,?,#,&,=untouched. Use this when encoding an entire URL where those characters carry meaning.
| Input | encodeURI | encodeURIComponent |
|---|---|---|
? | ? | %3F |
& | & | %26 |
/ | / | %2F |
space | %20 | %20 |
é | %C3%A9 | %C3%A9 |
i
Spaces in URLs. Spaces become %20 in path segments and + in application/x-www-form-urlencoded bodies. The two encodings are similar but not identical.
FAQ
When do I need to encode?
Whenever a string is placed inside a URL and could contain characters that aren't part of the URL grammar — query values, path segments built from user input, and anything passed in a redirect URL.
Why does decoding fail with "URI malformed"?
The input contains a % that isn't followed by two valid hex digits. This usually means the string was double-encoded or truncated.