How to URL Encode and Decode Strings
URL encoding (also called percent encoding) replaces unsafe characters with a % followed by their hexadecimal value. Spaces become %20, ampersands become %26, and non-ASCII characters like Γ© become %C3%A9. This encoding is required whenever you include user input, special characters, or non-ASCII text in URLs and query strings.
- Encode special characters for URLs and decode percent-encoded strings.
- What Gets Encoded.
- Covers url encoding in javascript.
- Covers decoding percent-encoded strings.
- Covers common encodings reference.
What Gets Encoded
Characters that have special meaning in URLs must be encoded when used as data: & (parameter separator), = (key-value separator), ? (query string start), # (fragment identifier), / (path separator), + and spaces. Non-ASCII characters (accented letters, emoji, CJK characters) are always encoded. The URL Encoder handles all of these β paste any string and get the encoded output.
URL Encoding in JavaScript
JavaScript provides two functions: encodeURIComponent() encodes a value for use as a query parameter β it encodes everything except letters, digits, and - _ . ~. encodeURI() encodes a full URL but preserves structural characters like : / ? # @. Use encodeURIComponent() for parameter values: '?search=' + encodeURIComponent(userInput). Use encodeURI() for complete URLs.
Decoding Percent-Encoded Strings
Decoding reverses the process: %20 becomes a space, %26 becomes &, %C3%A9 becomes Γ©. In JavaScript: decodeURIComponent('%C3%A9') returns 'Γ©'. The URL Encoder tool also decodes β paste a percent-encoded string and get the original text back.
background-size animation or @property registered custom properties instead.Common Encodings Reference
Space: %20 (or + in form data). &: %26. =: %3D. ?: %3F. #: %23. /: %2F. @: %40. +: %2B. %: %25. Non-ASCII characters use UTF-8 byte sequences: Γ© = %C3%A9, Γ± = %C3%B1, ΓΌ = %C3%BC.