CalculatorsConvertersDeveloperTextAll toolsDirectory
Submit your tool Sign in
Theme
Home/Answers/Developer
How-to

How do I URL-encode a string?

Short answer

Paste the string into a browser-based URL encoder and it percent-encodes every character that is not safe in a URL, so a space becomes %20 and an ampersand becomes %26. The encoding runs locally in your browser, so query values containing emails, tokens or search terms are never sent anywhere.

Why unencoded values break URLs

Characters like ?, &, = and # have structural meaning in a URL, so putting them raw inside a query value corrupts the request: everything after a stray & is read as a new parameter. Percent-encoding, defined in RFC 3986, replaces each unsafe byte with % followed by its hex value, which is why a properly encoded parameter survives any URL intact.

Encode components, not whole URLs

The classic mistake is encoding an entire URL, which mangles the :// and the path slashes. The rule is to encode each component, typically each query parameter value, on its own, the way JavaScript's encodeURIComponent does. A tool that encodes and decodes both directions also makes it easy to unpack an existing URL and see what a garbled parameter actually contains.

Step by step

  1. Open the encoder. Open the URL encoder in your browser.
  2. Paste the value. Paste the string to encode or decode. Processing is local.
  3. Copy the result. Copy the percent-encoded value into your URL or code.

Frequently asked questions

What is percent-encoding?

The standard from RFC 3986 that replaces unsafe characters with % plus their hex value, for example a space becomes %20.

Should I encode the whole URL?

No. Encode each component, such as an individual query parameter value. Encoding a full URL breaks its structure.

Is my input transmitted?

No. Encoding and decoding happen entirely in your browser.

Related answers