Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsA plus sign turns into a space when a query parameter is decoded using application/x-www-form-urlencoded rules. In that format, + represents a space, so a literal plus must be encoded as %2B. This is a form-style parameter convention, not a rule for every part of every URL.
Why does a plus sign turn into a space in a URL?
Many query-string tools use the application/x-www-form-urlencoded format for name-and-value pairs. Under its rules, spaces are serialized as + and a plus sign in a value is percent-encoded as %2B. If a value containing a literal + is passed to a form-style parser without that encoding, the parser reads it as a space. The WHATWG URL Standard defines this form encoding and its parsing behavior.
As an Amazon Associate I earn from qualifying purchases.
This is separate from generic URI syntax. RFC 3986 describes the URI query component, but does not make plus a universal synonym for space. The meaning depends on how the receiving software interprets the query data: a question mark in a URL does not, by itself, tell you which parser or parameter format is being used.
How do I keep a plus sign in a query parameter?
Encode the parameter value using the format the receiving endpoint expects. For form-style parameters, encode literal plus signs as %2B and let an encoder handle spaces and other reserved characters. For example, the value C++ becomes C%2B%2B; a space in the same format becomes +.
Prefer a query-parameter API that accepts raw keys and values over assembling a query string by joining text manually. The encoder can then distinguish a literal plus from the plus used to represent a space.
JavaScript: use URLSearchParams for form-style parameters
URLSearchParams serializes parameters using form-urlencoded rules. Its toString() method returns the query string without a leading question mark, and spaces are serialized as +. For example:
Rank #2
const params = new URLSearchParams({ q: "C++" });
const query = params.toString(); // q=C%2B%2B
See MDN’s URLSearchParams: toString() method reference.
Python: use urlencode for form-style parameters
urllib.parse.urlencode() uses quote_plus() by default. That matches form-style behavior: spaces become + and literal plus signs are escaped by default.
Rank #3
from urllib.parse import urlencode
query = urlencode({"q": "C++"})
# q=C%2B%2B
Python documents these functions in urllib.parse — Parse URLs into components.
When should spaces be encoded as %20 instead?
Use the representation specified by the receiving API. Some interfaces expect percent-encoded spaces as %20 rather than the form-style +. Python’s quote() is an alternative to quote_plus() for this kind of percent encoding. These approaches are not interchangeable in every context, so follow the endpoint’s parameter-format documentation rather than choosing based only on appearance.
| Encoding approach | Space representation | Literal plus representation | Use when |
|---|---|---|---|
| Form-style query encoding | + |
%2B |
The endpoint expects application/x-www-form-urlencoded semantics, as with Python urlencode() defaults and JavaScript URLSearchParams. |
Percent encoding with spaces as %20 |
%20 |
Use the encoder’s percent-encoding result for a literal plus, typically %2B. |
The API contract calls for this representation; Python’s quote() is one documented option. |
How should you decode a query parameter?
Use a decoder that matches how the value was encoded, and decode the parameter value rather than applying substitutions to the whole URL. Python’s unquote_plus() treats plus as a space; unquote() percent-decodes without that form-specific conversion. The distinction is documented in Python’s urllib.parse reference.
- For form-urlencoded data, use a form-aware parser or
unquote_plus(). - For data where plus is literal and spaces use percent encoding, use a compatible percent-decoder such as
unquote(). - Do not run repeated percent-decoding passes: RFC 3986 cautions that decoding more than once can change the meaning of data.
A global replacement such as changing every + in a URL to a space is unsafe. URLs have different components and parsing rules; such a replacement can corrupt a literal plus or alter text outside the parameter value.
Quick Recap
Best Value
Quick troubleshooting checklist
- Check the receiver’s contract: determine whether the endpoint expects form-urlencoded parameters or another query format.
- Check the encoded URL: a literal plus in a form-style value should appear as
%2B; a space in that format appears as+. - Check the parser: confirm it is parsing the query parameter using the same format used to encode it.
- Encode and decode once: avoid manual string replacements and repeated percent-decoding.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




