What is URL Encoding?
URL encoding (also called percent-encoding) converts special characters into a format that can be safely transmitted over the internet.
URLs can only contain certain characters from the ASCII character set. Characters outside this set must be encoded using a percent sign (%) followed by hexadecimal values.
When Do You Need URL Encoding?
- Query Parameters: Encoding search terms with spaces or special characters (?q=hello+world)
- API Requests: Safely passing data in URL parameters
- Form Submissions: Encoding form data sent via GET requests
- International Characters: Handling Chinese, Japanese, Arabic, etc. in URLs
- Special Characters: Encoding &, =, ?, #, @, etc. in URL values
URL Encode vs Encode Component
URL Encode (encodeURI):
- Encodes a complete URL
- Preserves URL structure characters like :, /, ?, &
- Use when encoding an entire URL
Encode Component (encodeURIComponent):
- Encodes URL parameters and values
- Encodes ALL special characters including :, /, ?, &
- Use when encoding individual query parameters
Common Characters Encoded
Space → %20
! → %21
# → %23
$ → %24
& → %26
' → %27
( → %28
) → %29
+ → %2B
/ → %2F
: → %3A
= → %3D
? → %3F
@ → %40
Related Tools