Why URLs Need Encoding
A URL can only contain a restricted set of ASCII characters. Spaces, accented letters, emoji, query separators like & and =, and many other characters have special meaning or are simply forbidden in raw URL form. Percent-encoding converts them into a safe %HH format.
How It Works
1. Take the character (e.g. space = byte 0x20)
2. Express each byte as %HH (two hex digits)
3. Space → %20 | & → %26 | = → %3D | # → %23
encodeURIComponent("hello world & more")
→ "hello%20world%20%26%20more"
encodeURI vs encodeURIComponent
- encodeURI: Encodes a full URL — leaves
/ ? # & = : @unencoded (they are valid URL structure characters). - encodeURIComponent: Encodes a URL component (like a query value) — also encodes
/ ? # & = + @. Use this for individual parameter values.
Common Encoded Characters
- Space → %20 (or
+in form data) - ! → %21 | " → %22 | # → %23 | $ → %24
- & → %26 | ' → %27 | ( → %28 | ) → %29
- + → %2B | , → %2C | / → %2F | : → %3A
- = → %3D | ? → %3F | @ → %40
Real-World Use Cases
- Search queries: Google encodes your search before sending it. "best pizza" →
q=best+pizza - OAuth tokens: Access tokens passed in query strings must be URL-encoded.
- File names: Files with spaces or special characters in their name need encoding when referenced in URLs.
- API parameters: Any user-input value passed as a URL query parameter should be encoded to prevent injection.
Encode or decode any URL or URL component instantly — 100% offline and private.
Try the URL Encoder →