URL Encoder
Percent-encode special characters for safe use in URLs and query strings.
What Is URL Encoding?
URL encoding (also called percent-encoding) converts characters that are not safe to appear in a URL into a % followed by two hexadecimal digits representing the character's UTF-8 byte value. For example, a space becomes %20, and an ampersand becomes %26.
This is necessary because URLs can only contain a limited set of ASCII characters. Any other character — including non-ASCII Unicode, spaces, and reserved punctuation — must be encoded before being placed in a URL.
encodeURIComponent vs encodeURI
This tool uses encodeURIComponent(), which is the correct function for encoding individual query string values or path segments. It encodes all characters except: A–Z a–z 0–9 - _ . ! ~ * ' ( ).
The related function encodeURI() is intended for encoding a complete URL and deliberately leaves URL structural characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) un-encoded. Use encodeURIComponent (this tool) when encoding a value that will be placed inside a query string.
Common Encoded Characters
| Character | Encoded | Description |
|---|---|---|
| Space | %20 | Word separator |
| & | %26 | Query string separator |
| = | %3D | Key=value separator |
| + | %2B | Sometimes used as space in forms |
| # | %23 | Fragment identifier |
| ? | %3F | Query string start |
| / | %2F | Path separator |
| : | %3A | Protocol / port separator |
| @ | %40 | Userinfo separator |
| % | %25 | The percent sign itself |
When to Use URL Encoding
Encode values before appending them to a URL in code: url + '?q=' + encodeURIComponent(searchTerm). Without encoding, a search term containing & or = would break the query string structure. URL encoding is also required for form submission values, redirect URLs passed as parameters, and any non-ASCII text in URLs.
Need more encoding tools? Try the full Encode & Decode suite.