MegaTools.live
← All guides

Put a search phrase into a URL

Build a query value that preserves spaces, ampersands and literal plus signs.

Encode the search phrase

For a search for tea & coffee, encode just those words. The result is tea%20%26%20coffee. The encoded ampersand belongs to the phrase. A bare ampersand in the query would introduce another parameter.

Open URL component encoder →

Check the round trip

Attach the result after ?q= in your search URL. To verify it, decode the value after the equals sign. You should recover tea & coffee. For C++, check that the encoded value is C%2B%2B.

Open URL component decoder →