🔗 URLTool
Encode, decode, and parse URLs
URL Encoding Explained
URL encoding (percent-encoding) converts characters that are unsafe or reserved in URLs into a %XX format. Without encoding, spaces, ampersands (&), and Unicode characters would break URLs or be interpreted as control characters by web servers.
The difference between encodeURI and encodeURIComponent is a common source of bugs: the former preserves URL structure characters (/, ?, &, #), while the latter encodes everything — use it for query string values, not entire URLs.
URL Structure Reference
- Protocol: https:// — defines the communication scheme
- Hostname: example.com — the server address
- Pathname: /blog/article — the resource path on the server
- Search/Query: ?key=value&foo=bar — parameters sent to the server
- Hash/Fragment: #section — client-side anchor, never sent to the server