URL Encoder/Decoder

Encode text for safe URL transmission or decode percent-encoded URLs. Essential tool for web developers working with URLs and query strings.

0 characters

About URL Encoding

URL encoding (also called percent-encoding) converts characters into a format that can be safely transmitted over the internet. Special characters are replaced with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII code.

Why URL Encoding is Necessary

🌐 Safe Transmission

URLs can only contain ASCII characters. Special characters must be encoded for safe transmission

🔗 Reserved Characters

Characters like ?, &, =, # have special meanings in URLs and must be encoded in data

🌍 Unicode Support

Enables use of international characters and emojis in URLs through UTF-8 encoding

📝 Query Parameters

Safely pass complex data, spaces, and special characters in query strings

Common Encoded Characters

CharacterEncodedUsage
Space%20 or +Most commonly encoded character
!%21Exclamation mark
#%23Hash (fragment identifier)
$%24Dollar sign
%%25Percent (encoding prefix)
&%26Ampersand (parameter separator)
+%2BPlus sign
=%3DEquals (key-value separator)
?%3FQuestion mark (query start)
@%40At symbol

encodeURIComponent vs encodeURI

encodeURIComponent

Use for: Query parameters, form data, individual URL parts

Encodes: All special characters including :, /, ?, #, &, =

encodeURIComponent('a=b&c=d')
→ a%3Db%26c%3Dd

encodeURI

Use for: Complete URLs that should remain valid

Preserves: URL structure characters :, /, ?, #, &

encodeURI('https://example.com/a b')
→ https://example.com/a%20b

Common Use Cases

  • Search Queries: Encode user input in search parameters (e.g., ?q=hello%20world)
  • Form Submissions: Safely transmit form data with special characters
  • API Requests: Pass parameters to REST APIs correctly
  • Email Links: Create mailto: links with encoded subjects and bodies
  • Social Sharing: Encode URLs for social media share buttons
  • Redirect URLs: Pass destination URLs as parameters

Reserved vs Unreserved Characters

✓ Unreserved (Safe)

Never need encoding:

  • • Letters: A-Z, a-z
  • • Digits: 0-9
  • • Special: - _ . ~

✗ Reserved (Must Encode)

Need encoding in data:

  • • Delimiters: : / ? # [ ] @
  • • Sub-delimiters: ! $ & ' ( ) * + , ; =
  • • Others: % space " < >

Frequently Asked Questions

What's the difference between %20 and + for spaces?

Both represent spaces, but %20 is the standard URL encoding. The + is specific to application/x-www-form-urlencoded format (HTML forms). Use %20 for general URLs.

Do I need to encode the entire URL?

No, only encode the parts that contain user data or special characters. Don't encode the protocol (https://), domain, or URL structure. Use encodeURIComponent for parameters and encodeURI for complete URLs.

Can I encode emojis and international characters?

Yes! URL encoding supports UTF-8, so any Unicode character can be encoded. Each character may result in multiple %XX sequences. Example: 😀 becomes %F0%9F%98%80

Is URL encoding the same as HTML encoding?

No, they're different. URL encoding uses %XX format for URLs. HTML encoding uses &name; or &#number; for HTML content. Use the right encoding for the right context.

Should I encode already-encoded URLs?

Be careful with double-encoding! Check if a URL is already encoded before encoding it again. Double-encoding turns %20 into %2520, which won't decode correctly.

Are hyphens and underscores safe in URLs?

Yes, hyphens (-), underscores (_), periods (.), and tildes (~) are unreserved characters that never need encoding. They're safe to use anywhere in URLs.