What Is URL Encoding?
URL encoding (also called percent-encoding) converts special characters in URLs into a format that can be transmitted safely over the internet. Characters that aren't allowed in a URL are replaced with a percent sign (%) followed by two hexadecimal digits.
Why URLs Need Encoding
URLs may only contain a specific set of ASCII characters. Characters like spaces, accents, Chinese characters, and symbols like &, =, # have special meanings in URLs and must be encoded when used as data.
Common URL Encoding Examples
| Character | Encoded Form | Why It Needs Encoding |
|---|---|---|
| Space | %20 | Spaces aren't valid in URLs |
| & | %26 | Separates query parameters |
| = | %3D | Separates key-value pairs |
| # | %23 | Fragment identifier |
| + | %2B | Alternative for space in forms |
| 中文 | %E4%B8%AD%E6%96%87 | Non-ASCII characters |
encodeURI vs encodeURIComponent in JavaScript
encodeURI(url)— Encodes an entire URL, leaving structural characters (: / ? # &) intact.encodeURIComponent(value)— Encodes a query parameter value, encoding& = # +etc. Use this for individual parameter values.
const search = "hello world & more";
encodeURIComponent(search); // "hello%20world%20%26%20more"
How to Encode/Decode URLs Online
- Open FavorTool URL Encoder.
- Paste the URL or query string value.
- Click Encode or Decode.
- Copy the result.