Awaiting input

Component vs full-URL encoding

Two operations exist in JavaScript:

InputencodeURIencodeURIComponent
??%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.