Percent-encode a URL or query string, or decode %XX sequences back to readable text. Choose between encodeURIComponent (query params) and encodeURI (full URLs). Runs in your browser.
| Character | Encoded | Notes |
|---|---|---|
| Space | %20 or + | + only valid in form data |
& | %26 | Separates query params |
= | %3D | Separates key=value |
+ | %2B | Literal plus sign |
/ | %2F | Path separator (encoded in params) |
# | %23 | Fragment identifier |
? | %3F | Query string start |
@ | %40 | Used in email addresses |
URL encoding (also called percent-encoding) converts characters that are not allowed or have special meaning in URLs into a safe format. Each unsafe character is replaced with a % sign followed by two hexadecimal digits representing the character's UTF-8 byte value. For example, a space becomes %20 and & becomes %26.
URLs can only contain a limited set of ASCII characters. Spaces, accented letters, Chinese characters, and special symbols must all be encoded before they appear in a URL — otherwise browsers and servers may misinterpret them.
encodeURIComponent encodes everything except: A–Z a–z 0–9 - _ . ! ~ * ' ( ). Use this for individual query parameter values. It will encode /, ?, #, &, and = — characters that are meaningful delimiters in a URL.
encodeURI preserves the structural characters of a complete URL: : / ? # [ ] @ ! $ & ' ( ) * + , ; =. Use this when encoding an entire URL that already has its structure in place — it won't break the path separators or query string delimiters.
URL encoding uses %XX sequences for unsafe characters. HTML encoding (HTML entities) uses &, <, etc. for characters that would break HTML markup. They solve different problems and should not be confused.