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
- Select URL Encode or URL Decode: Choose URL Encode to escape unsafe characters, or URL Decode to turn unreadable
%20and%26links back into human-readable text. - 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. - 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 %:
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.