URL Encode and Decode

Make text safe to put in a web address, or turn percent codes like %20 and %C3%A9 back into readable text. Paste a URL to see its parts and query parameters laid out.

Your results

–

How to use the URL encoder and decoder

  1. Choose what to do:
    • Encode a value for one piece of a URL, such as a search term or a parameter value.
    • Encode a whole URL to fix spaces and accented letters while keeping the URL working.
    • Encode form data to match what a browser sends from an HTML form, with + for spaces.
    • Decode to turn percent codes back into text.
  2. Type or paste your text. The result updates as you type.
  3. When decoding, keep Treat + as a space ticked for query strings and form data. Untick it for paths, where + is a literal plus sign.
  4. Copy the result with the Copy button. If the text is a URL, the tables below show its parts and every query parameter.

How percent-encoding works

A URL may only contain a limited set of ASCII characters, and some of them, like ? & = and #, have special jobs. Anything else is converted to bytes and written as a % followed by two hex digits for each byte:

Character → UTF-8 bytes → %XX for each byte space → %20 & → %26 é → C3 A9 → %C3%A9 € → E2 82 AC → %E2%82%AC

The rules come from RFC 3986. Letters, digits and - _ . ~ are always safe. Characters outside ASCII take two to four bytes in UTF-8, so one accented letter becomes six characters of code.

Worked example

The default value is café & crème:

  • c, a and f are safe and stay as they are.
  • é is the UTF-8 bytes C3 A9, so it becomes %C3%A9.
  • Each space becomes %20 and the ampersand becomes %26.
  • è is C3 A8, so it becomes %C3%A8; m and e stay.
  • Result: caf%C3%A9%20%26%20cr%C3%A8me, 28 characters.

With form encoding the spaces become plus signs instead: caf%C3%A9+%26+cr%C3%A8me. Decoding the default URL, https://example.com/search?q=caf%C3%A9+%26+cr%C3%A8me&lang=fr, gives back café & crème as the q parameter and fr as lang.

Which characters each mode leaves alone

Mode Left unencoded Typical use
Encode a value (encodeURIComponent) A–Z a–z 0–9 - _ . ! ~ * ' ( ) Query values, path segments, a URL inside another URL
Encode a whole URL (encodeURI) The above plus ; , / ? : @ & = + $ # Fixing a full link that has spaces or accents
Form data (application/x-www-form-urlencoded) A–Z a–z 0–9 - _ . * HTML form posts; spaces become +

Use the value mode for anything you insert into a URL. If you encode a whole URL with it, the slashes and colons are encoded too and the link stops working.

Common mistakes

Encoding twice. Running already-encoded text through an encoder again turns %20 into %2520. If you see %25 followed by two hex digits, the text was double-encoded; decode it once.

Mixing up + and %20. In a query string, + means a space. In a path it's a real plus sign. To send a literal + in a query value, encode it as %2B.

Building query strings by hand. A value containing & or = breaks the string unless it's encoded first. The value mode handles this for each parameter.

Frequently asked questions

What is URL encoding?

It's the way characters that aren't allowed in a URL are written as % followed by two hex digits, which is why it's also called percent-encoding. A space becomes %20 and é becomes %C3%A9. Browsers and servers decode the codes back into the original characters.

Should I use %20 or + for spaces?

Use %20 in paths and anywhere you aren't sure. The + form only means a space in query strings and form data, where browsers send it by default. Both decode to a space in a query string.

Why does decoding fail with an error?

Every % has to start a complete code: two hex digits, and for non-ASCII characters a full sequence of UTF-8 bytes. A lone %, a code like %ZZ, or a multi-byte character cut in half can't be decoded. The error message points to the part that's broken.

Is my text sent anywhere?

No. Encoding, decoding and the URL breakdown all run in your browser with its built-in functions. Nothing you paste is uploaded or stored.

Related calculators

  • Base64 Encode and Decode — Encode text to Base64 or decode Base64 back to text, with full UTF-8 support and the URL-safe variant.
  • Password Generator — Strong random passwords or word passphrases made in your browser, with the entropy and a strength rating for each.
  • IP Subnet Calculator — Network and broadcast address, usable host range, masks and binary view for any IPv4 or IPv6 subnet.

Results are calculated in your browser. Double-check anything important before you rely on it. See our disclaimer.