URL encoding, also called percent-encoding, replaces a character with a % sign and the two hexadecimal digits of each of its bytes, so a space becomes %20, an ampersand %26 and a slash %2F. Letters, digits and the four marks hyphen, period, underscore and tilde never need encoding. The rules below come from RFC 3986, the WHATWG URL Standard and MDN, checked on 24 November 2026, and every output in the tables was produced with Node.js v26.13.0 on the same day.
Characters that never need encoding
RFC 3986 section 2.3 calls these the unreserved characters: uppercase and lowercase letters A to Z, the digits 0 to 9, and the four marks - . _ ~. They mean the same thing whether they are encoded or not, and the RFC says percent codes for them can be decoded at any time. Encoding them is allowed but pointless, and RFC 3986 asks producers to use uppercase hex digits, such as %2F rather than %2f, for consistency.
Percent codes for symbols
The columns show what each common encoder outputs for the character on its own. encodeURIComponent is the JavaScript function for a single query value or path segment; encodeURI is for a whole address and leaves its structure alone; form encoding is the application/x-www-form-urlencoded format that HTML forms and URLSearchParams use.
| Character | Name | Percent code | encodeURIComponent | encodeURI | Form encoding |
|---|---|---|---|---|---|
| (space) | Space | %20 | %20 | %20 | + |
| ! | Exclamation mark | %21 | ! | ! | %21 |
| " | Double quote | %22 | %22 | %22 | %22 |
| # | Hash | %23 | %23 | # | %23 |
| $ | Dollar | %24 | %24 | $ | %24 |
| % | Percent | %25 | %25 | %25 | %25 |
| & | Ampersand | %26 | %26 | & | %26 |
| ' | Apostrophe | %27 | ' | ' | %27 |
| ( | Left parenthesis | %28 | ( | ( | %28 |
| ) | Right parenthesis | %29 | ) | ) | %29 |
| * | Asterisk | %2A | * | * | * |
| + | Plus | %2B | %2B | + | %2B |
| , | Comma | %2C | %2C | , | %2C |
| / | Slash | %2F | %2F | / | %2F |
| : | Colon | %3A | %3A | : | %3A |
| ; | Semicolon | %3B | %3B | ; | %3B |
| < | Less than | %3C | %3C | %3C | %3C |
| = | Equals | %3D | %3D | = | %3D |
| > | Greater than | %3E | %3E | %3E | %3E |
| ? | Question mark | %3F | %3F | ? | %3F |
| @ | At sign | %40 | %40 | @ | %40 |
| [ | Left bracket | %5B | %5B | %5B | %5B |
| \ | Backslash | %5C | %5C | %5C | %5C |
| ] | Right bracket | %5D | %5D | %5D | %5D |
| ^ | Caret | %5E | %5E | %5E | %5E |
| ` | Backtick | %60 | %60 | %60 | %60 |
| { | Left brace | %7B | %7B | %7B | %7B |
| | | Vertical bar | %7C | %7C | %7C | %7C |
| } | Right brace | %7D | %7D | %7D | %7D |
| ~ | Tilde | %7E | ~ | ~ | %7E |
Where the encodeURI column shows the character unchanged, such as # and &, that is deliberate: MDN explains that encodeURI leaves the reserved delimiters alone because they separate the parts of a full address. That is why a value containing & or = must go through encodeURIComponent, not encodeURI, or it will split into extra parameters.
The 18 reserved characters
RFC 3986 section 2.2 reserves characters that act as delimiters. When one of them is part of your data rather than the address structure, it must be percent-encoded.
| Group | Characters | Typical job in a URL |
|---|---|---|
| gen-delims (7) | : / ? # [ ] @ | Separate scheme, host, path, query and fragment |
| sub-delims (11) | ! $ & ' ( ) * + , ; = | Separate values inside a part, such as name=value&name=value |
Accented letters, symbols and emoji
RFC 3986 section 2.5 says new text should first be turned into bytes with UTF-8, and the WHATWG URL Standard percent-encodes every code point above U+007E. Each byte then becomes its own three-character code, so one visible character can become 6, 9 or 12 characters.
| Character | UTF-8 bytes | Encoded | Encoded length |
|---|---|---|---|
| é (e acute) | 2 | %C3%A9 | 6 characters |
| € (euro sign) | 3 | %E2%82%AC | 9 characters |
| 😀 (grinning face emoji) | 4 | %F0%9F%98%80 | 12 characters |
This matters for URL length limits, which count the encoded form.
Space: %20 or +?
Both are correct in their own place. In a path, and anywhere RFC 3986 rules apply, a space is %20. In form data, the WHATWG URL Standard writes a space as + when it uses the application/x-www-form-urlencoded percent-encode set, which is what HTML forms and URLSearchParams produce. A literal plus sign in a form value is therefore sent as %2B so it is not mistaken for a space. If a server shows plus signs where spaces should be, it is reading form data as plain percent-encoding, or the other way round.
Which characters each part of a URL encodes
Browsers follow the WHATWG URL Standard, which defines a different set of characters to encode in each part. Each set builds on the one above it.
| Percent-encode set | Adds these characters to the set above |
|---|---|
| C0 control | Control characters and everything above ~ (U+007E) |
| Fragment | space " < > ` |
| Query | space " # < > (added to C0 control, not fragment) |
| Special query (http, https and similar) | ' on top of query |
| Path | ? ^ ` { } on top of query |
| Userinfo | / : ; = @ [ \ ] | on top of path |
| Component | $ % & + , on top of userinfo; matches encodeURIComponent |
| Form urlencoded | ! ' ( ) ~ on top of component; space becomes + |
Common mistakes
- Double encoding. Encoding %20 again gives %2520. RFC 3986 section 2.4 warns that implementations must not encode or decode the same string more than once.
- Encoding a whole URL with encodeURIComponent. The :// and slashes become %3A%2F%2F and the link stops working. Encode only the values.
- A lone % sign. Text such as 50% off must be sent as 50%25%20off, or decoding fails.
- Lowercase hex. RFC 3986 treats %2f and %2F as equivalent, but asks producers and normalizers to use uppercase, so pick one style and stick to it when comparing or caching addresses.
To encode or decode text in your browser, use the URL Encoder and Decoder. Its Parameter value option uses encodeURIComponent, Full URL uses encodeURI, and Spaces as + gives form style output. For HTML rather than links, see the HTML entities list.
Sources and dates
| Page | Read | Used for |
|---|---|---|
| RFC 3986: URI Generic Syntax | 24 November 2026 | Percent-encoding, reserved and unreserved characters, uppercase hex, double encoding, UTF-8 |
| WHATWG URL Standard | 24 November 2026 | Percent-encode sets for each URL part and space as plus in form encoding |
| MDN: encodeURIComponent | 24 November 2026 | Characters left unescaped |
| MDN: encodeURI | 24 November 2026 | Characters left unescaped, including reserved delimiters |
Frequently asked questions
What is the URL encoding for a space?
%20. In form data, such as HTML form submissions and URLSearchParams, a space is written as a plus sign instead, and a real plus sign becomes %2B.
Which characters do not need URL encoding?
Letters A to Z and a to z, digits 0 to 9, and the marks hyphen, period, underscore and tilde. RFC 3986 calls them unreserved.
What does %2F mean in a URL?
It is an encoded slash. It lets a slash appear inside a value without being read as a separator between path segments.
Why does my URL show %2520?
The text was encoded twice. The % of %20 was itself encoded to %25, so decode it once or fix the code that encodes it a second time.
How are accented letters encoded in a URL?
Each letter is turned into UTF-8 bytes and every byte gets its own percent code, so é becomes %C3%A9 and the euro sign becomes %E2%82%AC.