URL encode and decode

Turn text into a URL-safe string with percent signs, or turn %20 style text back into readable text. Pick the version that fits: a part of a URL, a whole URL, or form data with plus signs. Your text stays in this browser.

URL encode and decode

How to URL encode or decode text

  1. Choose Encode or Decode.
  2. Paste your text. When encoding, choose A part of a URL, A whole URL or Form data.
  3. When decoding, leave Read + as a space ticked for form data, or untick it to keep plus signs.
  4. Tick Treat each line on its own for a list, so a bad line is named by its number.
  5. Press Copy result. Use result as input and switch makes the result the new input and flips the mode.

Which version to choose

Encode choices differ in which characters they leave alone. Use A part of a URL for one value: a query parameter, a path segment or a fragment. It escapes / ? & = : #, so the value cannot break the address around it. Use A whole URL for an address that already has its structure and only needs spaces and non-English letters fixed. It keeps / ? & = : #. Use Form data for the body of an HTML form, where a space is written as +.

The first and third choices behave like encodeURIComponent, and the second like encodeURI, with two differences we measured. The page also escapes ! ' ( ) *, which those functions leave as they are, and the whole-URL choice keeps [ and ] so an IPv6 address such as http://[::1]:8080/a b stays readable. Every character we tested is in the table below.

%20 or +

A space is %20 in a path and in most query strings. A plus sign is a space only in form data. When you decode, the option Read + as a space is on by default: a+b became a b, and with the option off it stayed a+b. A real plus sign in encoded text is written %2B, and that always decodes to +.

Double encoding

The percent sign is always escaped, in every choice, including Whole URL. Encoding a%20b again gave a%2520b, and decoding that gives back a%20b once. If a link shows %2520, it was encoded twice: decode once for each time it was encoded. Do not run Whole URL on an address that is already encoded.

Broken escapes

Decoding fails on a % that is not followed by two hex digits, and on bytes that are not valid UTF-8. We tried a lone % (100%), a%2, %ZZ, %FF, %80 and the cut-off %E0%A4%A. Each gave an empty result and a message instead of a changed text. Nothing is repaired silently.

The message quotes the text near the problem, and in a long text that quote can be wrong. For a%20b% it named %20b, which is a good escape, and the fault was the last %. Tick Treat each line on its own to get the line number: for three lines with %ZZ on the second, the page said Line 2 cannot be decoded. Check the escape near "%ZZ". Encoding a lone surrogate half (a broken character) also fails, with the same message about decoding.

Size and speed

Text of 1 MB encoded in about 0.4 seconds and decoded in about 0.3 seconds. At 5 MB it took about 3.6 and 3.0 seconds. Both round trips matched the original. Our Chinese, Japanese, Thai, Arabic and English samples matched Node's encodeURIComponent and decoded back unchanged. We did not test above 5 MB, and your computer may be slower or faster.

Where your text goes

We opened the page with outside connections blocked and typed a text that held a unique marker string, encoded and decoded it, then copied the result. Of 12 requests, 2 went to outside scripts (the Google ad script and tag), which we blocked, so we cannot say what they would send. No request carried a body or the marker, and localStorage and sessionStorage held no keys.

Other tools

Base64 is a different encoding with its own alphabet, handled by Base64 encode and decode. To read a query value that holds JSON, decode it here and paste it into the JSON formatter. To turn a finished link into a code, use the QR code generator.

Which characters each choice escapes

Test runs of the page in headless Chromium 158. Each character was typed alone and the result read from the page.
CharacterA part of a URLA whole URLForm data
space%20%20+
&%26&%26
=%3D=%3D
/%2F/%2F
?%3F?%3F
#%23#%23
+%2B+%2B
! ' ( ) *%21 %27 %28 %29 %2Aunchanged%21 %27 %28 %29 %2A
[ ]%5B %5Dunchanged%5B %5D
% " < > { } |escapedescapedescaped
~ - _ .unchangedunchangedunchanged
é%C3%A9%C3%A9%C3%A9
小%E5%B0%8F%E5%B0%8F%E5%B0%8F
emoji (grinning face)%F0%9F%98%80%F0%9F%98%80%F0%9F%98%80

Prefer desktop software?

The browser console runs encodeURIComponent and decodeURIComponent directly, curl --data-urlencode encodes form values on the command line, and every programming language has a library for it. We did not test them, so their handling of ! ' ( ) * and of plus signs may differ from this page. Node.js has the same encodeURIComponent as the browser console, and Python has urllib.parse.quote. The same caveat applies.

Frequently asked questions

What is the difference between encodeURI and encodeURIComponent?

encodeURI keeps the characters that give a URL its structure, such as / ? & = # and :. encodeURIComponent escapes them, which suits a single value. This page offers both as A whole URL and A part of a URL.

Should a space be %20 or +?

Use %20 in a path and when in doubt. A plus sign means a space only in form data, which is what the Form data choice writes.

Why does decoding say my text cannot be decoded?

A % must be followed by two hex digits, and the bytes must form valid UTF-8. A lone %, %ZZ or %FF all fail. Tick Treat each line on its own to see which line holds the problem.

Does it handle accents, Chinese and emoji?

Yes. Text is written as UTF-8 bytes, so é becomes %C3%A9 and an emoji becomes four escapes. Our five language samples matched Node's output and decoded back unchanged.

Why do I see %2520 in a link?

The link was encoded twice. The first pass wrote a space as %20, and the second wrote the % as %25. Decode once for each pass.

Is URL encoding a form of encryption?

No. Anyone can decode it, including with this page. It only makes text safe to put in an address.

Does this page upload my text?

No. The conversion runs in your browser and no request carries your text. In our test with outside connections blocked, no request had a body and none contained our marker string.