How to encode URL parameters: plus signs, Unicode and double encoding
A search term truncates at & or a space becomes %2520 when URL construction crosses the wrong encoding boundary. Distinguish a complete address from one parameter value before choosing the operation.
Open tool: URL encoder / decoder1. Encode one query value first
Choose URL component and encode a+b &中. Expect the value below. The ampersand belongs to the search text and must be escaped; otherwise, it may become a parameter separator when the URL is assembled.
Input: a+b &中
Encoded: a%2Bb%20%26%E4%B8%AD
URL: https://example.com/search?q=a%2Bb%20%26%E4%B8%AD2. Do not encode a full address as one value
Component mode escapes characters such as ?, & and =. Applying it to the whole https://example.com/search?q=hello address also escapes its structure. Full URL mode preserves those separators but cannot infer whether a particular & was intended as value content.
When constructing requests, let URLSearchParams handle query values instead of manually assembling strings and guessing which characters need escaping.
3. Plus and space depend on the encoding convention
This tool uses encodeURIComponent / decodeURIComponent: spaces become %20, literal plus signs become %2B, and decoding + alone keeps +. Form-style query serialization can instead represent spaces with +.
const params = new URLSearchParams({ q: "a+b c" });
console.log(params.toString()); // q=a%2Bb+c
console.log(params.get("q")); // a+b c4. Use %2520 to locate double encoding
Encoding a space yields %20. Encoding those three characters again produces %2520 because % becomes %25. Compare the original value, the value passed to the request library and the final URL to find the repeated transformation.
Decoding errors can also come from incomplete percent escapes or a different character encoding. Preserve the original rather than decoding repeatedly until it looks plausible.
5. Verify the final value in the actual request
Perform one encode and one decode in the URL tool and compare with the original, then inspect the value received by the server. The curl converter only adjusts shell quoting; it does not choose parameter encoding or execute the request.
- Distinguish a value, a full address and an address nested inside a value.
- Assign parameter encoding to one layer instead of repeating it in application and request-library code.