🔗 URL Parser & Encoder

Protocol · host · query params · encode · decode — all local

Advertisement

Break a URL into its parts (protocol, host, port, path, query, fragment, each parameter individually) or encode/decode components with the correct function. The classic bug: using encodeURI when you needed encodeURIComponent, sending half your value as a separate query parameter. This page shows the difference side-by-side.

Encode / Decode a component

—

encodeURI vs encodeURIComponent

encodeURIComponent encodes everything except A-Z a-z 0-9 - _ . ! ~ * ' ( ). Use it when putting user input into a single query value or path segment. encodeURI leaves the reserved characters ; , / ? : @ & = + $ # unencoded — use it only when encoding a whole URL that is already well-formed.

The example above: hello world&foo=bar encoded with encodeURI produces hello%20world&foo=bar, which on the server side decodes as two parameters, not one value. With encodeURIComponent the ampersand becomes %26 and the entire string stays one intact value.

Part of Everyday Tools. For Base64 and hashing see the Text Toolkit.

Advertisement
Advertisement