Percent-encode URLs and query parameters, or decode encoded URLs back to plain text. Handles full URLs or raw strings.
| Key | Value |
|---|
| Character | Encoded | Notes |
|---|---|---|
| space | %20 or + | %20 in paths; + in form data |
| & | %26 | Separates query params |
| = | %3D | Separates key from value |
| + | %2B | Encode + to avoid space confusion |
| / | %2F | Path separator — encode in values |
| # | %23 | Fragment identifier |
| @ | %40 | Used in userinfo of URL |
encodeURI encodes a full URL — it leaves :/?#[]@!$&'()*+,;= unencoded because they have meaning in a URL structure. encodeURIComponent encodes a single URL component (like a query parameter value) — it encodes those same special characters so they can safely appear inside a value without being misinterpreted. Use encodeURIComponent for individual values; encodeURI for a full URL you want to sanitize without breaking.