URL Encoder — Percent-Encode Strings for URLs Online
URL Encoder applies percent-encoding (also called URI encoding) to any string, converting special characters to their %XX equivalents. This is required whenever arbitrary text needs to appear in a URL query parameter or path segment. SmartDevBox uses the standard encodeURIComponent() encoding, which encodes all characters except A–Z, a–z, 0–9, -, _, ., and ~.
How Percent-Encoding Works
A URL can only contain a defined set of "safe" characters: unreserved characters (A–Z, a–z, 0–9, hyphen, underscore, period, tilde) and reserved characters that have specific structural meaning (/, ?, #, &, =, :, @, etc.). Any other character — spaces, accented letters, emoji, angle brackets — must be percent-encoded: replaced by a % followed by two hexadecimal digits representing the byte value. A space becomes %20, an ampersand becomes %26, a euro sign (€, U+20AC) becomes %E2%82%AC (its three-byte UTF-8 representation).
The RFC 3986 specification distinguishes two functions: encodeURI() leaves structural URL characters intact (so a complete URL remains a valid URL) while encodeURIComponent() encodes everything except unreserved characters. SmartDevBox uses encodeURIComponent(), which is the correct choice for encoding individual values like query parameter values, OAuth state tokens, or path segments containing dynamic user input.
Common Encoding Scenarios
Query string values are the most frequent use case. If a user searches for "C++ tutorial" and you append that directly to a URL as ?q=C++ tutorial, the + signs become a literal word separator in classic form encoding, and the space breaks the URL entirely. After encoding: ?q=C%2B%2B%20tutorial. Even better, use the URLSearchParams API in JavaScript, which handles encoding automatically.
OAuth redirect_uri parameters must be encoded when used as a query value within a larger authorization URL. Forgetting to encode them is a common bug that results in an "invalid redirect_uri" error from the authorization server, because the unencoded & in the redirect URI prematurely terminates the outer URL's query string.
Path segments containing slashes need special treatment. encodeURIComponent() encodes / as %2F. If your path segment contains a literal slash that should be treated as part of the segment value (not as a path separator), encode it. If you want it to act as a separator, leave it unencoded.
Common Use Cases
- Encoding query parameter values containing spaces or special characters
- Building URLs programmatically with dynamic user input
- Encoding OAuth redirect_uri and state parameters
- Preparing strings for inclusion in HTML href attributes
Frequently Asked Questions
What is URL encoding?
URL encoding (percent-encoding) converts characters that are not allowed in URLs into a % followed by two hexadecimal digits. For example, a space becomes %20, and & becomes %26.
What is the difference between encodeURI and encodeURIComponent?
encodeURI encodes a full URL and leaves characters like /, :, and ? intact. encodeURIComponent encodes a URL component (like a query value) and encodes those structural characters too. SmartDevBox uses encodeURIComponent.
Privacy & Security
This tool runs entirely in your browser using client-side JavaScript. No data is sent to a server — your input never leaves your machine. SmartDevBox has no account system, no usage tracking, and no paid tier. See the Privacy & Security page for full details.
Related Tools
- URL DecoderDecode any percent-encoded URL string back to readable text instantly in your browser. Free, no sign-up, 100% client-side.
- URL ParserParse any URL into its protocol, host, path, query parameters, and hash fragment instantly. Free, no sign-up, 100% client-side.
- Base64 EncoderEncode any text or string to Base64 instantly in your browser. Free, no sign-up, 100% client-side. Results copy with one click.
- HTML EncoderConvert special characters like < > & " to HTML entities instantly in your browser. Free, no sign-up, 100% client-side.