How RFC 3986 URL Percent-Encoding, encodeURIComponent & Query Strings Work

Why Reserved URL Characters Must Be Percent-Encoded

Under the internet's official URI specification (RFC 3986), web addresses may only contain a strict set of unreserved ASCII characters: letters (A–Z, a–z), digits (0–9), hyphens (-), underscores (_), periods (.), and tildes (~). Characters such as ?, &, =, /, #, spaces, and non-ASCII Unicode characters (like Hindi text or currency symbols ₹) carry structural control meanings inside HTTP requests. If you pass an unencoded ampersand (&) or space inside a query parameter, the web server splits your data prematurely—breaking OAuth redirects, UTM marketing links, and REST API endpoints.

How to Encode or Decode URLs in 3 Easy Steps

  1. Select URL Encode or URL Decode: Choose URL Encode to escape unsafe characters, or URL Decode to turn unreadable %20 and %26 links back into human-readable text.
  2. Pick Encoding Scope: Use encodeURIComponent when encoding a single query value or callback URL parameter, or encodeURI when preserving https://, /, ?, and & in a complete link.
  3. Inspect Parameters & Copy: Review the live parsed query-parameter cards below the editor and click Copy Output.

UTF-8 Percent-Encoding Formula & Worked Example

Percent-encoding converts every unsafe character into its UTF-8 hexadecimal byte sequence prefixed by %:

Percent-Encoded Byte = "%" + UppercaseHex( UTF8_Byte_Value )

Worked Example: Suppose you pass the search phrase "Price: ₹500 & Free" as a query parameter value using encodeURIComponent().

Spaces become %20, colon becomes %3A, ampersand becomes %26, and the 3-byte UTF-8 Rupee symbol (₹ = 0xE2 0x82 0xB9) becomes %E2%82%B9.

Final safe query value = Price%3A%20%E2%82%B9500%20%26%20Free.

Common URL Percent-Encoding Character Reference Chart (16 Characters)

Use this developer reference table to verify exact percent-encoded hex codes and see which characters encodeURI vs. encodeURIComponent escape.

Character Description Percent-Encoded Escaped by encodeURI?
(space) ASCII Space (0x20) %20 (or + in forms) Yes (Both)
! Exclamation Mark %21 No (encodeURIComponent only)
" Double Quote %22 Yes (Both)
# Hash / Fragment Identifier %23 No (Reserved fragment)
$ Dollar Sign %24 No (encodeURIComponent only)
% Percent Sign (Escape Prefix) %25 Yes (Both)
& Ampersand (Query Separator) %26 No (encodeURIComponent only)
+ Plus Sign %2B No (encodeURIComponent only)
, Comma %2C No (encodeURIComponent only)
/ Forward Slash (Path Delimiter) %2F No (encodeURIComponent only)
: Colon (Scheme / Port Separator) %3A No (encodeURIComponent only)
= Equals Sign (Key-Value Divider) %3D No (encodeURIComponent only)
? Question Mark (Query Start) %3F No (encodeURIComponent only)
@ At Symbol %40 No (encodeURIComponent only)
[ ] Square Brackets (IPv6 Hosts) %5B / %5D Yes (Both)
₹ Indian Rupee Symbol (UTF-8) %E2%82%B9 Yes (Both)

Encoding Base64 tokens, formatting JSON responses, generating QR codes, or converting text cases? Explore our companion tools:

Frequently Asked Questions

Use encodeURIComponent whenever you are encoding a parameter value (such as a redirect URL, search query, or user email) to append after ?key=—because it escapes &, =, ?, and / so they don't corrupt your query string. Use encodeURI only when you want to encode a complete, already-assembled URL while keeping https:// and / intact.
Standard RFC 3986 URI encoding represents a space as %20, whereas HTML form submissions (application/x-www-form-urlencoded) historically encoded spaces as +. Our URL Decoder automatically handles both %20 and + cleanly.
This happens if the input contains a literal % sign that is not followed by two valid hexadecimal digits (for example, "50% off" instead of "50%25 off"), or if a multi-byte UTF-8 sequence was cut off mid-character.
Never. All percent-encoding, decoding, and query-parameter parsing execute 100% locally inside your web browser using JavaScript. Your URLs never leave your device.