URL Encoder

Percent-encode text so it can travel safely in a URL, entirely in your browser.

Runs entirely in your browser. Nothing is uploaded, logged or stored.

A URL has a grammar, and characters that belong to it — "?", "&", "/", "#", spaces — have to be escaped when they are part of a value rather than part of the structure. That escaping is percent-encoding.

How it works

Every character outside the unreserved set of RFC 3986 — letters, digits, "-", ".", "_" and "~" — is replaced by a percent sign and the hexadecimal value of each of its UTF-8 bytes. A space becomes %20 and an accented letter becomes two escapes, because it is two bytes in UTF-8.

The form data style exists because HTML form submissions predate that rule: there a space is "+" and "~" is escaped as well. Pick it when you are building an application/x-www-form-urlencoded body, and the component style for everything else.

Examples

Case Input Result
A search phrase going into a query string coffee & cake coffee%20%26%20cake
The same phrase as form data coffee & cake coffee+%26+cake

Frequently asked questions

Should I encode a whole URL with this?

No. Encoding a complete URL escapes the "://" and the separators too, and leaves you with a string no client can follow. Encode the individual values, then assemble the URL from them.

Why is "!" encoded here when my browser console leaves it alone?

JavaScript's encodeURIComponent deliberately skips "!", "'", "(", ")" and "*" although RFC 3986 reserves them. Encoding them is always accepted and avoids surprises in stricter parsers, so this tool does.

What about the "#" in a fragment?

A literal "#" inside a value must be encoded as %23, otherwise everything after it is read as the fragment and never reaches the server.

Good to know

  • Everything happens in your browser. What you paste is not uploaded, not logged and not stored.

Sources

All Code tools