Encode OAuth Redirect URIs
URL Encoding Reference
encodeURI vs encodeURIComponent
encodeURIComponent: Encodes all special characters including /, ?, &, =, #. Use for encoding URL parameter values.
encodeURI: Preserves URL structure characters (/, ?, &, =, #, :). Use for encoding entire URLs while keeping them valid.
Code Examples
Here's how to achieve this in different programming languages:
1// URL Encode2const input = "https://myapp.com/auth/callback?source=google&next=/dashboard";3const encoded = encodeURIComponent(input);4console.log(encoded); // "https%3A%2F%2Fmyapp.com%2Fauth%2Fcallback%3Fsource%3Dgoogle%26next%3D%2Fdashboard"56// URL Decode7const decoded = decodeURIComponent("https%3A%2F%2Fmyapp.com%2Fauth%2Fcallback%3Fsource%3Dgoogle%26next%3D%2Fdashboard");8console.log(decoded); // "https://myapp.com/auth/callback?source=google&next=/dashboard"
Frequently Asked Questions
What is the URL encoding of "https://myapp.com/auth/callback?source=google&next=/dashboard"?
The URL encoding of "https://myapp.com/auth/callback?source=google&next=/dashboard" is "https%3A%2F%2Fmyapp.com%2Fauth%2Fcallback%3Fsource%3Dgoogle%26next%3D%2Fdashboard". URL encoding converts special characters to percent-encoded format using %XX hexadecimal values.
How do I URL encode text?
Use encodeURIComponent() in JavaScript, urllib.parse.quote() in Python, or Uri.EscapeDataString() in C#. Our online tool above encodes instantly.
How do I decode URL-encoded text?
Use decodeURIComponent() in JavaScript, urllib.parse.unquote() in Python, or Uri.UnescapeDataString() in C#.
Why do spaces become %20?
The hex value of space (ASCII 32) is 20. URL encoding uses %XX format where XX is the hex value. So space → %20, @ → %40, & → %26.
What's the difference between encodeURI and encodeURIComponent?
encodeURIComponent encodes ALL special characters (/, ?, &, =) for use in URL parameter values. encodeURI preserves URL structure and is used for whole URLs.