English text is the one case where percent-encoding barely changes anything visible — letters, digits, and most punctuation are already in the URL-safe set. The characters that actually need escaping are the small set with structural meaning: space, &, ?, #, +, and a handful of others.
What actually gets encoded
Every unsafe byte becomes a percent sign followed by its two-digit hex value: a space becomes %20, & becomes %26, # becomes %23. Because ASCII characters are already single bytes, English text only expands where it hits one of these reserved characters — unlike scripts that need multi-byte UTF-8 encoding for every letter.
encodeURIComponent vs encodeURI
encodeURIComponent escapes nearly everything with structural meaning — &, ?, =, / — so it's the right choice for a single value going into a query parameter, like a redirect URL passed as ?next=. encodeURI leaves those structural characters alone and is meant for encoding a complete URL you already assembled, path and query string included.
The classic OAuth redirect bug
A redirect_uri passed as a query parameter has to be encoded, or its own ? and & get parsed as part of the outer URL instead of the value — this is a recurring source of "invalid redirect_uri" errors in OAuth flows, where the callback URL itself contains query parameters that need escaping before being embedded in the authorization request.
When you need this
- Passing a value with spaces or special characters as a single query parameter.
- Building links with dynamic values — search terms, IDs, callback URLs.
- Debugging: decoding a URL to see what data is actually packed into it.
Edge case: the space character has two encodings
A space becomes + in application/x-www-form-urlencoded data — the format used by HTML forms and traditional query strings — but %20 in strict RFC 3986 percent-encoding, which is valid anywhere in a URL. Mixing the two conventions is a common bug: decoding a modern API's query string as form data turns literal + characters into spaces they were never meant to represent.