AD · 728×90
Google AdSense / Яндекс.Директ
Google AdSense / Яндекс.Директ
URL
encodeURIComponent()
Encodes a URI component by replacing special characters with percent sequences
String to encode
encodeURIComponent(uriComponent)
RESULT
— click Run or press Ctrl+Enter —
Parameter Reference
| Parameter | Type | Status | Description |
|---|---|---|---|
| uriComponent | string | required | String to encode |
About
encodeURIComponent() escapes all characters except letters, digits, and -_.!~*'() using percent-encoding (%XX). Essential when building URLs with query parameters containing Cyrillic, spaces, or special characters. Unlike encodeURI(), it also encodes /, ?, #, and & — suitable for encoding parameter values, not full URLs.
Browser Support
Introduced in ES3 (1999) as a replacement for the deprecated escape(). Supported by all browsers without exception.
Tips & Gotchas
- Use for parameter values, not full URLs — for full URLs use encodeURI()
- spaces become %20, not + (unlike HTML form encoding)
- always encode user input before interpolating into a URL.