Developer Encoding

URL encoder

What to do

Processed in your browser · nothing is uploaded

Local · pick the right one or lose data silently

Two encodings, because they do different jobs: component encoding escapes &, =, / and ? so a value can sit inside a query string; whole-URL encoding leaves those alone because they are the structure.

How to use the url encoder

1 Paste the text. Encode component is selected first, which is the right choice for a value going into a query string.
2 Switch to Encode whole URL only when you are tidying a complete address rather than one of its values.
3 Decode turns percent escapes back into text, and turns a plus into a space.
4 Copy the result, or save it as a file.

Using the wrong one is the classic bug. Encoding a whole URL with component encoding turns https://x.com/a?b=c into https%3A%2F%2Fx.com%2Fa%3Fb%3Dc, which no browser will follow. Encoding a query value with whole-URL encoding leaves an ampersand in it, which splits the parameter and truncates the value with no error anywhere: the data simply stops at the ampersand. Rule of thumb: component encoding for anything going into a URL, whole-URL encoding for a URL you are cleaning up. The sample above makes the split visible. search?q=a b&filter=x/y comes back from component encoding as search%3Fq%3Da%20b%26filter%3Dx%2Fy, with every structural character escaped, and from whole-URL encoding as search?q=a%20b&filter=x/y, with only the space touched.

Percent-encoding works on bytes, not on letters, and the bytes are UTF-8. An é becomes %C3%A9, two escapes for one character, and an emoji becomes four. So a length limit anywhere in a URL is a limit on bytes: a 100-character query value in Japanese is 300 bytes once encoded. It also means that decoding is where a mismatched character set shows up, as replacement characters rather than as an error.

Three traps account for most of the confusion. Both encoders escape an existing % as %25, which is correct and is why encoding twice compounds: a b becomes a%20b and then a%2520b, and one decode only gets you back to a%20b; a value that survived two systems usually needs two decodes. Whole-URL encoding leaves # alone as structure, so a genuine hash inside a value has to be escaped by hand or everything after it becomes the fragment and never reaches the server. And decoding treats + as a space before anything else happens, which is correct for form-encoded query data and wrong for a path or a Base64 blob: C++ decodes to C followed by two spaces. Encoding with the component encoder first avoids that, because it writes a plus as %2B.

What people use it for

  • Escaping a search term before it goes into a query string
  • Reading a redirect URL that has been encoded twice over
  • Working out why a parameter value stops at the ampersand
  • Turning a percent-encoded path from a server log back into text
  • Putting an email address or a filename into a link safely

Questions

Component encoding escapes the structural characters too, for values going into a URL. Whole-URL encoding leaves them, for a URL you are cleaning up.

MDN, encodeURIComponent()RFC 3986 §2, percent-encoding and the unreserved set
Was this tool any good?
Internal signal only · I use it to find the tools worth rebuilding