Skip to content
OddsockLocal
Local
Source text

Formatting

5 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste the value, not a full URL you hope to keep intact.
  2. Leave Direction on encode.
  3. Copy the percent-encoded text. Spaces are %20.
  4. Decode to check the round trip. Plus signs are not produced here.

What is URL encoder?

URL encoder uses encodeURIComponent, the function you want for a single parameter value. a b/c?d=e&f becomes a%20b%2Fc%3Fd%3De%26f. Space is %20, slash is %2F, question mark is %3F, equals is %3D, ampersand is %26. If those characters were left raw, they would split the query into extra parameters.

Read more

encodeURI is the other standard function, and this page does not call it. encodeURI would encode the space and leave / ? & = in place, which is right for a whole URL and wrong for one value. The query builder is a third spelling: it writes spaces as +, because it uses form encoding. Pick the page that matches the consumer. Direction starts on encode. Decode runs decodeURIComponent, which turns %20 back into a space and does not treat + as a space.

Encoding is not encryption. a%20b%2Fc is trivial to reverse on the decoder page. There is no key.

Use cases

  • A query value contains a slash and an ampersand, and both have to be %2F and %26 so they do not break the URL.
  • You need %20 for a space because the server does not treat + as a space.
  • You are comparing encodeURIComponent with the query builder, which would have written a+b for the same space.
  • A value might be encoded twice, and you want to see %2520 appear after a second pass.

One component, every reserved character encoded

Direction encode. a b/c?d=e&f

a%20b%2Fc%3Fd%3De%26f

Why use Oddsock

The slash and the ampersand are the reason to use this page. A function that leaves them raw is encoding a URL, not a component.

Related tools

Using this tool

encodeURI is for a whole URL. It encodes spaces and leaves characters that structure the URL, including / ? & =. encodeURIComponent is for one piece. It encodes those characters too. This page runs encodeURIComponent, so a b/c?d=e&f becomes a%20b%2Fc%3Fd%3De%26f. encodeURI would have kept the slash, the question mark, the equals sign and the ampersand.