URL Encoder/Decoder
Input
Output
URL Encoding Reference
| Character | Encoded | Description |
|---|---|---|
space | %20 or + | Space character |
! | %21 | Exclamation mark |
# | %23 | Hash/Number sign |
$ | %24 | Dollar sign |
% | %25 | Percent sign |
& | %26 | Ampersand |
' | %27 | Apostrophe |
+ | %2B | Plus sign |
/ | %2F | Forward slash |
= | %3D | Equals sign |
? | %3F | Question mark |
@ | %40 | At sign |
About URL Encoding
What is URL Encoding?
URL encoding (percent-encoding) converts characters into a format that can be safely transmitted in URLs. Special characters are replaced with % followed by their hexadecimal value.
Safe Characters
These characters don't need encoding: A-Z, a-z, 0-9, - (hyphen), _ (underscore), . (period), ~ (tilde)
When to Encode
- Query string parameters
- Form data (application/x-www-form-urlencoded)
- Path segments with special characters
- Non-ASCII characters in URLs
How to Use This Tool
- Enter Your Input: Paste text containing special characters to encode, or a percent-encoded string to decode. The tool handles spaces, ampersands, equals signs, and all other reserved URL characters.
- Click Encode or Decode: Use "Encode" to convert special characters to percent-encoded format (%XX), or "Decode" to restore the original text. Enable "Encode all characters" for maximum encoding (rarely needed).
- Copy the Result: Click "Copy" to copy the encoded/decoded string. For query parameters, remember that both keys and values should be individually encoded before joining with "&" and "=".
- Use in Your URL: Insert the encoded string into your URL path or query string. Spaces become %20 (or + in query strings), ampersands become %26, preventing parsing ambiguity.
Technical Details
URL encoding (percent-encoding) replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits representing the character's byte value. RFC 3986 defines unreserved characters (A-Z, a-z, 0-9, -, _, ., ~) that never need encoding. Reserved characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) have special meaning in URLs and must be encoded when used as data rather than delimiters.
UTF-8 characters are encoded as multiple percent-encoded bytes. For example, "ü" (U+00FC) becomes %C3%BC (its UTF-8 byte sequence). JavaScript's encodeURIComponent() encodes all characters except unreserved ones, suitable for query parameter values. encodeURI() preserves URL structure characters, suitable for full URLs. This tool uses encodeURIComponent() logic, appropriate for encoding values within URLs.
Common Mistakes to Avoid
- Double Encoding: Encoding an already-encoded string produces invalid results. "%20" becomes "%2520" (the % gets encoded). Always decode before re-encoding, or verify input isn't already encoded by checking for % followed by hex digits.
- Encoding Full URLs: Don't encode entire URLs—this breaks the structure. Encode only the data portions (parameter values, path segments containing user input). The URL's structural characters (://?#&=) should remain unencoded.
- Spaces as Plus Signs: Historically, "+" meant space in query strings (application/x-www-form-urlencoded). Modern usage prefers %20 for consistency. When decoding, be aware that "+" might represent a space in legacy query strings, not a literal plus sign.
Related Tools
Need to encode binary data for transmission in JSON or data URLs? Use our Base64 Encoder. For escaping HTML content that includes special characters, try the HTML Entity Encoder.
Frequently Asked Questions
What's the difference between encodeURI and encodeURIComponent?
encodeURI() preserves URL structure characters (://?#&=) and is for encoding complete URLs. encodeURIComponent() encodes everything except unreserved characters and is for encoding individual parameter values or path segments within a URL.
Should I encode spaces as + or %20?
Use %20 for consistency across all contexts. The + convention for spaces only applies in application/x-www-form-urlencoded format (HTML form submissions). %20 is universally recognized and avoids ambiguity with literal plus signs.
Why does my URL break when I encode it?
You likely encoded the entire URL including its structure. Only encode the data portions—user input in path segments or query parameter values. The colons, slashes, question marks, and other structural characters should remain unencoded.