Skip to content
FreeToolsKit.app

Text & Writing guide

How to URL-Encode a Query Parameter Value

8 min read · Updated 20 November 2026 · Uses URL Encoder & Decoder

Quick answer

Encode the parameter value on its own, once, and then put it after the =. Don't encode the whole link. Characters that have a job in a URL must become a % followed by two hexadecimal digits: & separates parameters, # starts the fragment, and + means a space in a query string. Spaces and non-ASCII letters such as é must be encoded too, byte by byte in UTF-8. The URL standard says data that "would conflict with a reserved character's purpose as a delimiter" must be percent-encoded (RFC 3986, section 2.2).

In FreeToolsKit's URL Encoder & Decoder:

  1. On the Encode tab, keep URI component (RFC 3986): space → %20.
  2. Paste only the value into Text to encode and press Encode.
  3. Put the Encoded result after q= (or your parameter name). Then check it in the Query Inspector: you should see one parameter with your exact text.

In code, JavaScript's encodeURIComponent() and Python's quote() with safe="" gave the same result for this guide's test value.

URL Encoder & DecoderFree to use · No account required · Converted in your browserOpen URL Encoder & Decoder

Find your symptom

Each symptom below has one usual cause. The fixes follow in the next sections.

  • The value stops at &: a raw & starts a new parameter. Form parsing splits the query "on 0x26 (&)" (WHATWG URL Standard: urlencoded parser).
  • Plus signs arrive as spaces: the same parser will "Replace any 0x2B (+) in name and value with 0x20 (SP)". A real plus sign must be sent as %2B.
  • Everything after # is missing: the query is "terminated by a number sign" (RFC 3986, section 3.4). The part after it is the fragment, which is "separated from the rest of the URI prior to a dereference", so the server never receives it (section 3.5).
  • You see %2520, or the page shows %20 instead of a space: the value was encoded twice.
  • A decoder reports a malformed sequence: there's a raw % in the text, or the text was encoded in an old character set instead of UTF-8.

The example is a fictional search page, https://example.com/search, with one parameter, q. The search term is:

  • Value: Fish & Chips + Peas #1 café
  • Size: 27 characters, 28 bytes in UTF-8, because é (U+00E9) takes two bytes, C3 A9.
  • Trouble characters: 6 spaces, &, +, # and é.

What happens when the value is left raw

With the value pasted straight after q=, the link looks fine but doesn't carry the search term.

  • What the browser kept: Chromium's own URL parser encoded the spaces as %20 but left &, + and # alone. The query became everything before the #, and #1 café became the fragment.
  • What the tool showed: pasting the raw query into the Query Inspector and pressing Analyze query gave an error: "A raw # at position 23 starts a URL fragment, which isn't part of the query string."
  • How the rest split: pasting the part the browser does send (before the #) gave "2 parameters, in their original order".
    • Parameter 1: name q, value "Fish " with a trailing space.
    • Parameter 2: the rest of the text became a parameter name, "Chips" and "Peas" with the + turned into a space (three spaces between the two words), and "No value (no = sign)".

So the search page would receive "Fish " and a stray parameter, and never see #1 café. MDN gives the same warning for "Jack & Jill": without encoding, "the ampersand could be interpreted on the server as the start of a new field" (MDN: encodeURIComponent()).

  1. Open the Encode tab. Under Encoding format, keep URI component (RFC 3986): space → %20.
  2. In Text to encode, paste only Fish & Chips + Peas #1 café.
  3. Press Encode. The tool reported "Encoded as a URI component (RFC 3986): 27 → 50 characters."
  4. Read the Encoded result. Here it is in three pieces, which run together with no spaces:
    • Fish%20%26%20Chips
    • %20%2B%20Peas
    • %20%231%20caf%C3%A9
  5. Use Copy result or Download .txt (the file was url-encoded.txt, 50 bytes), and paste it after q=.

Each character was replaced as follows:

  • Space: %20
  • &: %26
  • +: %2B
  • #: %23
  • é: %C3%A9, one %XX for each of its two UTF-8 bytes.

Check it. In the Query Inspector, q= followed by the encoded value gave "1 parameter", with the value Fish & Chips + Peas #1 café exactly.

Two whole-link mistakes to avoid:

  • Encoding the whole link as a component: this turned 56 characters into 91, starting https%3A%2F%2Fexample.com. The :, /, ? and = that make it a link became data, so it no longer works as a link. The tool itself says "Encode one component at a time, not a whole URL."
  • Using encodeURI() on the whole link: it deliberately leaves ; / ? : @ & = + $ , # alone because they "may be part of the URI syntax" (MDN: encodeURI()). In Node it encoded the spaces and é but kept &, + and #. The Query Inspector again found 2 parameters, the same split as the raw link.

%20 or +?

Both mean a space in a query string. They come from two conventions:

  • %20 (URI component): the percent-encoding of a space from RFC 3986. It means a space anywhere in a URL.
  • + (form encoding): HTML forms use application/x-www-form-urlencoded, where a space is written +. URLSearchParams encodes a space "as +", while URL.search "encodes spaces as %20" (MDN: URLSearchParams).

With Form/query value (WHATWG): space → + selected, the same value came out at 38 characters instead of 50. Each space became +, while the real plus sign stayed %2B. In the Query Inspector, both versions decoded to the identical value.

Where + is not a space: outside form decoding, + is just a plus sign. decodeURIComponent() leaves it alone, which is why MDN's example replaces + with a space before decoding a query value (MDN: decodeURIComponent()). In the tool, decoding Fish+%26+Chips gave "Fish+&+Chips" with URI component and "Fish & Chips" with Form/query value. So match the decoding format to how the value was encoded, and always send a real plus sign as %2B.

The same results in code:

  • JavaScript (Node 22): encodeURIComponent() gave exactly the tool's 50-character component result. URLSearchParams gave the 38-character form result.
  • Python: quote(value, safe="") matched the component result. quote_plus() and urlencode() matched the form result. quote() leaves / unencoded unless you pass safe="", because its default is '/', and quote_plus() is the one documented "as required for quoting HTML form values" (Python: urllib.parse).
  • One difference: encodeURIComponent() leaves ! ' ( ) * as they are, while the tool's component mode encodes them. This test value has none of them, so the outputs matched.

Spot and fix double encoding

Symptom: the link contains %2520, or the page displays %20 or caf%C3%A9 instead of the text.

Cause: a value that was already encoded went through the encoder again. The % itself is then encoded as %25. RFC 3986 says implementations "must not percent-encode or decode the same string more than once" (RFC 3986, section 2.4).

In the test, encoding the 50-character result a second time gave 72 characters. Every % became %25, so %20 turned into %2520 and %C3%A9 into %25C3%25A9. In the Query Inspector, that double-encoded query gave one parameter whose value still read Fish%20%26%20Chips…, the tell-tale sign.

Fix: decode one step at a time, and look after each step.

  1. Open the Decode tab and keep URI component (RFC 3986): space → %20.
  2. Paste caf%25C3%25A9 into Encoded text to decode and press Decode. The result was caf%C3%A9: still encoded, because "Decoding is strict and runs exactly once".
  3. Decode that result again. It gave café.
  4. For the whole test value, the first decode went from 72 to 50 characters and the second from 50 to 27, matching the original exactly.
  5. Then encode the clean text once, as in the previous section.

Don't decode until no % is left. A value can legitimately contain % (100% is written 100%25), so another decode would corrupt it. Repeated decoding is also how attackers slip past filters that "only decode user input once" (OWASP: Double Encoding). Find out where the extra encoding happened and remove it there.

When the decoder reports an error

The tool's decoder is strict: it reports bad input instead of guessing. On the Decode tab, the three malformed values in the test gave these messages:

  • 100%: "Incomplete percent escape at position 4: a % must be followed by two hexadecimal digits. A literal % is written as %25."
  • 50%off: "Invalid hexadecimal digit in percent escape at position 3: a % must be followed by two of 0–9 and A–F. A literal % is written as %25."
  • caf%E9: "The encoded bytes are not valid UTF-8: an incomplete multi-byte sequence at the percent escape at position 4."

The last one is é encoded in the older Windows-1252 character set, which the tool page lists as unsupported. In UTF-8, é is %C3%A9. Re-encode the original text rather than editing the escapes by hand.

Other decoders:

  • JavaScript: decodeURIComponent() threw a URIError for all three. MDN documents it for "a % not followed by two hexadecimal digits" or an escape that "does not encode a valid UTF-8 character" (MDN: decodeURIComponent()).
  • Python: unquote() raised nothing. It returned 100% and 50%off unchanged and turned caf%E9 into "caf" plus a replacement character, because by default "invalid sequences are replaced by a placeholder character" (Python: urllib.parse). A lenient decoder like this can hide the problem.
  1. Only the value is encoded: the ?, the = and any & between parameters are still raw.
  2. No raw trouble characters: the value contains no raw space, &, +, # or non-ASCII letter.
  3. The split is right: the Query Inspector shows the number of parameters you expect, and each value reads exactly as intended.
  4. No stray %25: it appears only if the original text really contains a %.
  5. One decode gives the original: decoding the value once, in the same format, gives back your text.

Building campaign links? The UTM Campaign URL Builder encodes each parameter for you.