encodeURIComponent vs encodeURI
encodeURIComponent escapes almost everything, including / ? & = and #, so it is the right choice for a single query value or path segment.
encodeURI keeps those reserved characters intact, so it suits a complete URL where only spaces and non-ASCII characters need escaping.
Parsing a URL
Paste a URL to see its protocol, host (with port), path and hash. The query string appears as a table of keys and values that you can edit, add to or remove from.
The rebuilt URL updates instantly, with every value escaped correctly.
Common pitfalls
- Do not run encodeURIComponent on a whole URL, it would escape the slashes and colon
- A literal % must be written %25, otherwise decoding fails
- In query strings a space may appear as + or %20; both decode to a space here

