Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › percent-encoding

How to Preserve Plus Signs and Ampersands in Search URLs

By Freedom251 Team · · 2 min read

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build the URL from its parts: leave = and & in place when they separate query parameters, but percent-encode a plus sign or ampersand that is literal data inside a value as %2B or %26. This prevents the receiving application from mistaking your search text for URL syntax.

Why plus signs and ampersands can change a search URL

In a common query string, an equals sign connects a parameter name to its value, while an ampersand separates one parameter from the next. Google Search Central describes this pattern in its URL structure guidance.

As an Amazon Associate I earn from qualifying purchases.

For example, in ?q=red&page=2, the first ampersand separates the q parameter from page. If the search value itself contains a raw ampersand, a parser using this convention may treat the text after it as another parameter instead of part of the search.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Plus signs need care for a different reason. RFC 3986 classifies both + and & as reserved URI characters; what they mean depends on the URI component and the application interpreting it. Some form-style query parsers treat an unencoded plus as a space, but that is not a universal rule for every URI parser.

Encode literal characters, not query structure

When a character is part of the search value rather than a separator, use its percent-encoded form:

Character in the value Encode as Why
Literal plus sign (+) %2B A form-style parser may interpret an unencoded plus as a space.
Literal ampersand (&) %26 A raw ampersand commonly separates query parameters.

Keep structural characters intact. In ?q=C%2B%2B&mode=exact, %2B%2B preserves the two literal plus signs in the value, while the raw ampersand still separates the q and mode parameters.

This follows the distinction in RFC 3986: when data in a URI component would conflict with a reserved character’s delimiter purpose, the conflicting data must be percent-encoded before the URI is formed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Build and check a demo search URL

  1. Identify the parameters. Write the parameter names and values you need, such as q for the search and page for a page number.
  2. Mark literal characters in each value. Encode a plus sign as %2B and an ampersand as %26 if either belongs to the search text and the receiving parser could treat it as syntax.
  3. Join the URL components. Use = between each parameter name and value and a raw & between separate parameters.
  4. Check the result in the target application. Confirm that it displays or searches for the intended text; exact interpretation depends on that application’s query parser.

Parse before decoding

Percent-encoded sequences represent octets in a URI component. RFC 3986 advises separating URI components before decoding those sequences: decoding a reserved character too early can turn encoded data such as %26 into a raw ampersand that appears to be a parameter boundary. Keep the encoded form through parsing, then decode the value at the appropriate stage for the receiving application.

Generic URI syntax versus form-style query parsing

Generic URI syntax does not make plus universally synonymous with space. That behavior comes from form-style query conventions used by some applications. The W3C’s historical URI documentation describes plus as a shorthand for a space in that context and says a literal plus must be encoded there. For reliable sharing, use %2B when the plus is data and check the target application’s rules if exact interoperability matters.

Quick Recap

SaleBestseller No. 1

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.

percent-encodingSearchURLsweb standards

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.