Encode a value, not the whole address
URL encoding represents characters as percent escapes so that data can travel inside a URL without being confused with its structure. The important first question is what you are encoding: a single value, a form value, or a complete URI. Characters such as an ampersand can be part of the data in one place and a separator in another. Choose the boundary before converting anything.
For a search parameter named q with the value red & blue, encode the value on its own in Component mode. Then place it after the parameter name and equals sign. The encoded ampersand stays inside the value instead of starting another parameter:
Value: red & blue
Encoded value: red%20%26%20blue
Assembled URL: https://example.com/search?q=red%20%26%20blue
Do not put the entire assembled address through Component mode: it would encode separators such as the colon, slashes, question mark, and equals sign as data. If there are several parameters, encode each name and value as appropriate, then join them using the separators required by the receiving application.
How to encode text for a link
- Identify the exact piece of text the destination expects, and keep a copy of the original. Do not include surrounding URL punctuation unless it is part of the value itself.
- Choose Encode and select Component for an ordinary parameter value. Choose Form value only when the receiving system expects form-encoded data; use Full URI only when its rules fit the task.
- Enter the unencoded value and review the result. Spaces and line breaks are data, so check for accidental extra characters rather than silently removing them.
- Copy the result into its intended position, or pass it to the application that requested it. Test with a harmless example to confirm the destination receives the intended value.
Developers should also check what their URL-building library does. APIs that serialize query parameters can encode values for you; handing them an already encoded value may encode its percent signs again. Provide raw values when the API expects raw values, and inspect the serialized URL rather than concatenating another encoding step by habit.
Spaces, plus signs, and Unicode
Component mode uses JavaScript encodeURIComponent. It represents a space as %20 and a literal plus sign as %2B. Form value mode uses the form serialization convention: a space becomes +, while an actual plus still becomes %2B. These outputs differ, but both can represent the same original value when interpreted using the matching rules.
Original: a+b c
Component: a%2Bb%20c
Form value: a%2Bb+c
Unicode text is encoded as UTF-8 bytes and then represented with percent escapes where needed. For example, Component mode converts hello 世界 to hello%20%E4%B8%96%E7%95%8C. The receiver must interpret the encoded bytes correctly; encoding does not translate or shorten the original words.
A raw + is not universally a space. In Component decoding it remains a plus; in Form value decoding it means a space. When a plus is literal data in a form value, using %2B prevents that ambiguity.
Put one URL inside another
Sometimes a complete URL is itself the value of a parameter, such as a return destination. In that case the inner URL is data from the outer URL's point of view. Encode the inner URL as one Component value, then attach it to the outer parameter without encoding the outer separators. This example uses fictitious addresses:
Inner URL: https://example.com/page?x=1&y=2
Encoded inner value: https%3A%2F%2Fexample.com%2Fpage%3Fx%3D1%26y%3D2
Outer URL: https://example.org/continue?next=https%3A%2F%2Fexample.com%2Fpage%3Fx%3D1%26y%3D2
The outer query parser can recover the inner address as one value; whether it will be accepted or used depends on the destination application. If an inner URL already contains an escape, encoding its percent sign for the outer layer can be necessary. Preserve the original and follow the receiving system's specification rather than adding or removing layers at random.
Choose the right encoding mode
- Component: Uses
encodeURIComponentanddecodeURIComponentfor a single component. JavaScript leaves some characters, including!,',(,), and*, unescaped, so this is not a claim of stricter RFC 3986 escaping. - Form value: Applies form serialization rules to one value, not to an entire query string. Its rules differ beyond spaces too:
~!*()becomes%7E%21*%28%29. Use the matching form rules when interpreting the result. - Full URI: Uses
encodeURIanddecodeURI, which treat URI delimiters differently from component functions. This mode is not a general repair tool and cannot tell whether an ampersand was intended as data or as a separator.
For instance, Full URI encoding of https://example.com/search?q=red & blueproduces https://example.com/search?q=red%20&%20blue. The ampersand remains a separator; if it belongs to the search value, encode that value separately instead. Full URI mode also turns an existing %20 into %2520 when encoding, so it should not be applied blindly to an already encoded address. JavaScript's encodeURI also escapes the brackets in an IPv6 host such as https://[2001:db8::1]/, potentially making the address invalid. Do not use its output as a link without checking the address.
Avoid unintended extra encoding
Seeing %2520 may indicate that %20 was encoded again, but it does not prove an error. The original data might contain those literal characters, or a nested value might legitimately require another layer. Check the source, the expected data, and each application's handling before deciding. Do not automatically encode or decode a second time, and do not replace percent escapes by hand just because they look unusual.
Likewise, decoding an entire URL can change its meaning. Component decoding can turn an encoded slash or ampersand into a structural character; even making an address more readable is not the same as preserving a navigable link. Work on the relevant value, retain the original address, and review the result before using or sharing it.
Troubleshooting and common questions
Why did decoding report an error?
Decoding is strict. A lone percent sign, %ZZ, or incomplete or invalid UTF-8 such as %E9 cannot be decoded as valid input. Check that every escape has two hexadecimal digits, that the text was copied completely, and that the source uses UTF-8. Do not guess missing bytes or repeatedly decode in an attempt to force a result.
Why does the receiving page show the wrong value?
Check whether you encoded the value rather than the full query, selected the expected form or component convention, and allowed a library to encode it again. Compare the original and the value received by the destination using a non-sensitive test. Some applications impose additional rules or validate allowed return addresses, so a correctly encoded value alone does not guarantee acceptance.
Is URL encoding encryption?
No. Percent escapes are reversible and do not hide a password, access token, or personal information from someone who sees the URL. Do not paste real tokens or passwords into this tool or put secrets in a shareable link. Text conversion happens locally in your browser, but the website also uses analytics; see the privacy policy for details.
Need to inspect an encoded value? Use the URL decoder. To inspect a whole URL and its query parameters, use the URL parser. To remove recognized tracking parameters instead of encoding text, visit the URL Cleaner homepage.