URL Encoder

URL encode text for safe links. Free URL encoder.

Encode as

Rate this tool

How useful was this tool?

URL Encoder

Paste a link or a piece of text into Text or URL to encode, or load the Example. Then choose how to encode it under Encode as:

  • a whole URL: each part by its own rules, as a browser does
  • a value for a query string or a path segment: everything that could break a URL is encoded, including &, =, / and ?
  • every character, even the safe ones: letters and digits too, so abc becomes %61%62%63

Two options adjust the result:

  • Spaces as + (form style, like PHP urlencode) writes spaces the way HTML forms send them, instead of %20.
  • Keep existing %XX escapes (do not encode the % sign again) leaves text that’s already encoded alone. More on both below.

The result appears under Encoded, with Copy and Use the result as input. Below it you get the number of escapes, the characters in and out, a round-trip check, the URL part by part and a table of everything that was encoded. Clear starts over.

Example: a link with spaces and accents

https://example.com/café menu/?ref=newsletter&utm_campaign=Spring Sale

encoded as a whole URL becomes:

https://example.com/caf%C3%A9%20menu/?ref=newsletter&utm_campaign=Spring%20Sale

The summary reads 4 percent escapes, 70 characters in, 79 out. The slashes, the ?, the & and the = are untouched, because they give the URL its structure.

The URL, part by part shows the scheme (https), the host (example.com), the path (/caf%C3%A9%20menu/) and the query. The query parameters get a table of their own, with each value decoded and encoded:

Name Value (decoded) Encoded
ref newsletter ref=newsletter
utm_campaign Spring Sale utm_campaign=Spring%20Sale

What was encoded lists each character with its escape and its UTF-8 bytes:

Character Escape UTF-8 bytes Times
space %20 20 2
é %C3%A9 C3 A9 1

That’s where the count of 4 comes from: é is two bytes in UTF-8, so it takes two escapes, and each space takes one. Most accented letters are two bytes, € is three (%E2%82%AC) and an emoji is four (😀 is %F0%9F%98%80).

Whole URL or value?

A whole URL is encoded the way a browser treats what you type in the address bar. The characters that are safe differ per part: a slash is fine in the path, a question mark starts the query, a hash starts the fragment. So each part is encoded by its own rules.

A value is what goes inside a URL: a search term, a campaign name, a redirect address. Here &, =, /, ? and # must be encoded too:

salt & pepper   →   salt%20%26%20pepper

Put the unencoded version into a query, and it breaks. ?q=salt & pepper&page=2 reaches the server as q = “salt “, plus a parameter called “ pepper” with no value: the & inside the value started a new parameter. In whole-URL mode the tool can’t know which & you meant as a separator, and the note says so. Encode such a value on its own first, with the value option, then put it into the link.

The same goes for a URL passed as a parameter, as in a redirect or a share link. Encoded as a value, https://example.com/a?b=c becomes https%3A%2F%2Fexample.com%2Fa%3Fb%3Dc, safe to put after ?redirect=.

Every character encodes even letters and digits. You’ll rarely need it, but it’s handy for seeing the bytes behind any text, or for checking how a server decodes unusual input.

Existing escapes and literal percent signs

With Keep existing %XX escapes ticked, text that’s already partly encoded keeps its escapes: %20 stays %20 instead of becoming %2520. That double encoding is a common bug. A link encoded twice shows up in analytics as Spring%2520Sale, and can lead to a 404. Lower-case escapes are upper-cased, so %e2%82%ac becomes %E2%82%AC, the form the URL standard recommends.

Untick it when a percent sign is meant literally, as in “50% off”, or in a token like k7%41x, where %41 would otherwise be read as the letter A. Every % then becomes %25, and “50% off” turns into 50%25%20off.

Spaces: %20 or +?

By default spaces become %20, which is correct everywhere in a URL. A + means a space in only one place: a query string in the format HTML forms submit. Tick Spaces as + (form style, like PHP urlencode) when the receiving side expects that format.

Everywhere else, a + is just a plus sign, and that has a consequence. In a query, a real plus sign must be encoded as %2B, or it turns into a space. Search for C++ with ?q=C++, and many servers read “C” followed by two spaces. Encoded properly, it’s ?q=C%2B%2B.

The round-trip check

The line under the result decodes the output and compares it with what you typed. For a value, decoding gives back exactly your input.

For a whole URL, decoding gives back the URL as the browser normalised it. A browser tidies some parts that don’t change where the link leads. For example, it writes the scheme and domain in lower case and adds the / after a bare domain, so HTTPS://Example.COM becomes https://example.com/. When the parser can’t read the text as a URL at all, such as with a space inside the domain name, you get a clear error rather than a half-encoded result.

Domain names are a special case: accented domains aren’t percent-encoded but converted to Punycode, a different system. Unicode to Punycode shows that form.

Where it’s useful

  • Campaign links. UTM values with spaces or accents, like utm_campaign=Spring Sale, need encoding before they go into an email or an ad. Otherwise the link breaks or the campaign name arrives cut short.
  • Links with non-English paths. Pages with accented or non-Latin slugs work in browsers. But in emails, chat apps and some CMS fields the raw characters get mangled, while the encoded form survives anywhere.
  • Parameters that contain URLs. Redirect targets, share links and callback addresses must be encoded as a value.
  • API requests. Search terms and filters with &, + or / must be encoded as values before they’re added to a request URL.
  • Email links. In a mailto: link, a subject with spaces needs %20. A + stays a plus sign there, so leave the form-style option off.

FAQ

Which characters get encoded?

Spaces, non-ASCII characters (accents, other alphabets, emoji), control characters, and anything not allowed where it appears. In a whole URL, the separators / ? # & = stay as they are. In a value they’re encoded too, and with “every character”, so is everything else.

How do I decode a URL?

Use the URL Decoder. It turns %XX escapes back into readable text.

What’s the equivalent in code?

  Value, spaces as %20 Value, spaces as + Whole URL
JavaScript encodeURIComponent() — encodeURI()
PHP rawurlencode() urlencode() —
Python urllib.parse.quote() urllib.parse.quote_plus() —

Is URL encoding the same as HTML entities or Base64?

No. URL encoding makes text safe inside a URL. HTML entities make text safe inside a web page, and Base64 turns any data into plain letters and digits. A link inside an HTML attribute can need both URL encoding and an & for each &.

Note: All processing is done client-side. We do not store or see your data.

Contact

Missing something?

Feel free to request missing tools or give some feedback using our contact form.

Contact Us