URL Encode & Decode · Tutorial

How to encode a value for a URL query parameter

5 min readbeginnerUpdated

You're building a link by hand, such as a pre-filled form, a search URL or a tracking link, and the value contains spaces, accents, & or #. Pasted as it is, part of the value disappears or the link breaks. This tutorial shows how to encode each value correctly and assemble a working URL.

What you need

  • The URL Encode & Decode
  • The values you want to put in the link (the Try it button loads a sample)

Steps

  1. Identify the values

    A query string is a list of name=value pairs joined by &, after a ?. Only the values (and sometimes the names) need encoding, never the ?, = and & that separate them. In the sample, the values are Amara Okafor, São Paulo and Order #42 & gift wrap.

  2. Encode each value

    Choose A value (query parameter, path segment) and paste a single value, for example Order #42 & gift wrap. The result is Order%20%2342%20%26%20gift%20wrap. The # and & are now safe.

    Order #42 & gift wrap  →  Order%20%2342%20%26%20gift%20wrap
  3. Encode a list at once

    To encode several values, put each on its own line and tick Each line separately. Each line is encoded on its own, so you can copy them one by one.

  4. Assemble the URL

    Join the encoded values with their names. Notice that São Paulo became S%C3%A3o%20Paulo, because ã is two bytes in UTF-8.

    https://example.com/form?name=Amara%20Okafor&city=S%C3%A3o%20Paulo&note=Order%20%2342%20%26%20gift%20wrap
  5. Test the link

    Open the link in a browser and check that the page receives every value in full. You can also paste it into the URL Parser to see each parameter decoded.

Try it yourself

Opens the URL Encode & Decode with this tutorial's sample loaded.

Try it now

Common mistakes

Encoding the whole URL as a value
If you encode the full link in value mode, its : and / become %3A and %2F and the link stops working. Encode values only, or use A full URL for complete addresses.
Encoding twice
Encoding an already-encoded value turns %20 into %2520. If you see %25, the text was encoded twice.
Using + for spaces in paths
A + means a space only in form-encoded query strings. In a URL path it's a literal plus sign. Use %20 unless you're sure the receiver expects form encoding.

Next steps

Go back to the URL Encode & Decode, or keep going with one of these:

FAQ

Do I need to encode letters with accents?

Modern browsers display them fine, but many systems, emails and older software don't handle raw non-ASCII URLs well. Encoding is always safe.