How URL Encoding Works: Why Chinese Characters Become %E4%...
When you see %E4%B8%AD in the address bar, that's URL encoding (percent-encoding) at work. It lets Chinese characters and special symbols appear safely in a URL.
Why encode URLs
URLs only allow a subset of ASCII characters. Spaces, Chinese, &, = and the like would be misinterpreted and must be encoded as % plus two hex digits.
encodeURI vs encodeURIComponent
- encodeURI keeps structural chars like ? # / — for whole URLs
- encodeURIComponent encodes more thoroughly — for a single parameter value
- Use the latter when concatenating query strings
Encode/decode online
FreeToolset's URL tool converts both ways, handy for debugging API parameters.
💡 When a parameter value contains &, always use encodeURIComponent, or it'll be treated as a new parameter separator.