Convert between URLs and percent-encoding both ways, with URI component / full URL modes, and break query parameters into a table.
| Component | Example | Encoding notes |
|---|---|---|
| Scheme | https | Never encoded |
| Host | example.com | Use Punycode for non-Latin domains |
| Port | 443 | Digits only |
| Path | /docs/page | Encode each segment; / is significant |
| Query | ?q=hello world | Encode names and values separately |
| Fragment | #section | Not sent to the server |
Unreserved characters — letters, digits, and -, _, ., ~ — never need encoding. Everything else becomes a percent sign followed by two hex digits: a space is %20, a slash is %2F when it is meant as data rather than as a separator. The reserved set (: / ? # [ ] @ ! and others) has structural meaning, so encoding it changes the URL's interpretation.
Both appear, and they are not interchangeable. In the path, a space must be %20. In a query string submitted as form data, + is the traditional encoding for a space — which is exactly why a literal plus sign inside a query value must itself be encoded as %2B. Sending a raw + where a space is expected, or the reverse, is one of the most common causes of a mysteriously altered search term.
If a value is encoded and then passed through a system that encodes it again, %20 becomes %2520 and arrives as literal text. Always establish which layer is responsible for encoding — usually the client, once — and make sure nothing downstream repeats it.
The fragment is handled by the browser and is never transmitted, so it does not need transfer encoding — but characters significant to the page's own routing may still need escaping. And because the fragment survives redirects and is used by single-page applications, malformed encoding there can break navigation without ever reaching the server logs.