| Char | Decimal | Hex | URL Encoded | Name |
|---|---|---|---|---|
| 32 | 0x20 | %20 | Space | |
| ! | 33 | 0x21 | no encoding needed | Exclamation mark |
| " | 34 | 0x22 | %22 | Double quote |
| # | 35 | 0x23 | %23 | Hash / Number sign |
| $ | 36 | 0x24 | %24 | Dollar sign |
| % | 37 | 0x25 | %25 | Percent sign |
| & | 38 | 0x26 | %26 | Ampersand |
| ' | 39 | 0x27 | no encoding needed | Single quote / Apostrophe |
| ( | 40 | 0x28 | no encoding needed | Left parenthesis |
| ) | 41 | 0x29 | no encoding needed | Right parenthesis |
| * | 42 | 0x2A | no encoding needed | Asterisk |
| + | 43 | 0x2B | %2B | Plus sign |
| , | 44 | 0x2C | %2C | Comma |
| - | 45 | 0x2D | no encoding needed | Hyphen / Minus |
| . | 46 | 0x2E | no encoding needed | Period / Dot |
| / | 47 | 0x2F | %2F | Forward slash |
| 0 | 48 | 0x30 | no encoding needed | Zero |
| 1 | 49 | 0x31 | no encoding needed | |
| 2 | 50 | 0x32 | no encoding needed | |
| 3 | 51 | 0x33 | no encoding needed | |
| 4 | 52 | 0x34 | no encoding needed | |
| 5 | 53 | 0x35 | no encoding needed | |
| 6 | 54 | 0x36 | no encoding needed | |
| 7 | 55 | 0x37 | no encoding needed | |
| 8 | 56 | 0x38 | no encoding needed | |
| 9 | 57 | 0x39 | no encoding needed | Nine |
| : | 58 | 0x3A | %3A | Colon |
| ; | 59 | 0x3B | %3B | Semicolon |
| < | 60 | 0x3C | %3C | Less-than |
| = | 61 | 0x3D | %3D | Equals sign |
| > | 62 | 0x3E | %3E | Greater-than |
| ? | 63 | 0x3F | %3F | Question mark |
| @ | 64 | 0x40 | %40 | At sign |
| A | 65 | 0x41 | no encoding needed | Capital A |
| B | 66 | 0x42 | no encoding needed | |
| C | 67 | 0x43 | no encoding needed | |
| D | 68 | 0x44 | no encoding needed | |
| E | 69 | 0x45 | no encoding needed | |
| F | 70 | 0x46 | no encoding needed | |
| G | 71 | 0x47 | no encoding needed | |
| H | 72 | 0x48 | no encoding needed | |
| I | 73 | 0x49 | no encoding needed | |
| J | 74 | 0x4A | no encoding needed | |
| K | 75 | 0x4B | no encoding needed | |
| L | 76 | 0x4C | no encoding needed | |
| M | 77 | 0x4D | no encoding needed | |
| N | 78 | 0x4E | no encoding needed | |
| O | 79 | 0x4F | no encoding needed | |
| P | 80 | 0x50 | no encoding needed | |
| Q | 81 | 0x51 | no encoding needed | |
| R | 82 | 0x52 | no encoding needed | |
| S | 83 | 0x53 | no encoding needed | |
| T | 84 | 0x54 | no encoding needed | |
| U | 85 | 0x55 | no encoding needed | |
| V | 86 | 0x56 | no encoding needed | |
| W | 87 | 0x57 | no encoding needed | |
| X | 88 | 0x58 | no encoding needed | |
| Y | 89 | 0x59 | no encoding needed | |
| Z | 90 | 0x5A | no encoding needed | Capital Z |
| [ | 91 | 0x5B | %5B | Left square bracket |
| \ | 92 | 0x5C | %5C | Backslash |
| ] | 93 | 0x5D | %5D | Right square bracket |
| ^ | 94 | 0x5E | %5E | Caret |
| _ | 95 | 0x5F | no encoding needed | Underscore |
| ` | 96 | 0x60 | %60 | Backtick / Grave |
| a | 97 | 0x61 | no encoding needed | Lowercase a |
| b | 98 | 0x62 | no encoding needed | |
| c | 99 | 0x63 | no encoding needed | |
| d | 100 | 0x64 | no encoding needed | |
| e | 101 | 0x65 | no encoding needed | |
| f | 102 | 0x66 | no encoding needed | |
| g | 103 | 0x67 | no encoding needed | |
| h | 104 | 0x68 | no encoding needed | |
| i | 105 | 0x69 | no encoding needed | |
| j | 106 | 0x6A | no encoding needed | |
| k | 107 | 0x6B | no encoding needed | |
| l | 108 | 0x6C | no encoding needed | |
| m | 109 | 0x6D | no encoding needed | |
| n | 110 | 0x6E | no encoding needed | |
| o | 111 | 0x6F | no encoding needed | |
| p | 112 | 0x70 | no encoding needed | |
| q | 113 | 0x71 | no encoding needed | |
| r | 114 | 0x72 | no encoding needed | |
| s | 115 | 0x73 | no encoding needed | |
| t | 116 | 0x74 | no encoding needed | |
| u | 117 | 0x75 | no encoding needed | |
| v | 118 | 0x76 | no encoding needed | |
| w | 119 | 0x77 | no encoding needed | |
| x | 120 | 0x78 | no encoding needed | |
| y | 121 | 0x79 | no encoding needed | |
| z | 122 | 0x7A | no encoding needed | Lowercase z |
| { | 123 | 0x7B | %7B | Left curly brace |
| | | 124 | 0x7C | %7C | Pipe / Vertical bar |
| } | 125 | 0x7D | %7D | Right curly brace |
| ~ | 126 | 0x7E | no encoding needed | Tilde |
| Function | Encodes | Leaves alone | Use for |
|---|---|---|---|
| encodeURIComponent() | Everything except A-Z a-z 0-9 - _ . ! ~ * ' ( ) | Alphanumerics + - _ . ! ~ * ' ( ) | Query param values, path segments |
| encodeURI() | Unsafe chars, preserves : / ? # [ ] @ ! $ & ' ( ) * + , ; = | Most URI structural chars | Full URLs |
| escape() ✗ | Non-ASCII + some ASCII (deprecated) | @ * / + | Never — deprecated, use encodeURIComponent |
// Encode a single query param value (most common)
encodeURIComponent('hello world!') // → 'hello%20world!'
encodeURIComponent('price=100&qty=2') // → 'price%3D100%26qty%3D2'
// Build a URL with params safely
const params = new URLSearchParams({ q: 'hello world', page: '2' });
const url = 'https://example.com/search?' + params.toString();
// → https://example.com/search?q=hello+world&page=2
// Decode percent-encoded string
decodeURIComponent('hello%20world') // → 'hello world'
// Python
import urllib.parse
urllib.parse.quote('hello world') # → 'hello%20world'
urllib.parse.quote_plus('hello world') # → 'hello+world'
urllib.parse.urlencode({'q': 'hello world'}) # → 'q=hello+world'The most common use case. When building search URLs or API requests:
https://api.example.com/search?q=hello%20world&lang=en
HTML forms with method="GET" URL-encode field values automatically. Spaces become + in form encoding (slightly different from percent-encoding).
File names and resource identifiers in URL paths need encoding too. A file named my report.pdf becomes my%20report.pdf in the URL.
JavaScript:
encodeURIComponent('hello world & more')
// "hello%20world%20%26%20more"
decodeURIComponent('hello%20world')
// "hello world"
Python:
from urllib.parse import quote, unquote
quote('hello world & more')
# 'hello%20world%20%26%20more'
%20 into %2520encodeURI instead of encodeURIComponent — encodeURI skips reserved characters that matter in query values+ signs — In URLs, + can mean space. Encode literal plus signs as %2BForm encoding (application/x-www-form-urlencoded) uses + for spaces. Standard percent-encoding uses %20. Both are valid in different contexts.
URL encoding replaces unsafe ASCII characters with a percent sign (%) followed by two hexadecimal digits representing the byte value. For example, a space becomes %20 or +. This ensures URLs are valid across all systems and protocols.
RFC 3986 defines which characters are 'unreserved' (A-Z, a-z, 0-9, -, _, ., ~) and safe to use without encoding. All other characters — including spaces, <, >, #, %, {, }, |, \, ^, `, and non-ASCII characters — must be percent-encoded.
%20 is the RFC 3986 standard percent-encoding of a space and works everywhere in a URL. The + sign for spaces is part of the application/x-www-form-urlencoded format (HTML forms) and is only valid in query strings, not in paths.
Use encodeURIComponent() to encode individual query parameter values: encodeURIComponent('hello world') → 'hello%20world'. Use encodeURI() to encode a full URL while preserving its structure. Never use escape() — it is deprecated.
No. It encodes bytes for a particular URL context. Encode parameter values separately from complete URLs, and agree on which layer decodes them. Repeated encoding changes percent signs and can break interpretation. Validate destinations and application rules separately; a syntactically encoded URL is not automatically safe to follow or publish.