URL Encoder and Decoder

Percent-encode text for a URL or decode it back, split a link into parts, and build query strings.

Encode or decode text

Break a URL into parts

Build a query string

How to encode or decode a URL

  1. Choose Encode or Decode at the top of the tool.
  2. Type or paste into Text to encode (or Encoded string to decode). The page opens with an example already filled in.
  3. When encoding, pick a method: encodeURIComponent, encodeURI (whole URL), RFC 3986 strict or Form (+ for spaces). When decoding, tick or clear Treat + as a space (form data).
  4. Click Copy, or Swap to move the result back into the input and flip the mode, which shows whether your text survives the round trip.
  5. Use Break a URL into parts to inspect a link and Build a query string to assemble parameters.

How percent-encoding works

Percent-encoding, defined in RFC 3986 section 2.1, writes each byte of a character's UTF-8 form as a percent sign and two hex digits, so the Japanese character 日 becomes %E6%97%A5. The four methods differ only in which characters they leave alone. The JavaScript behavior follows MDN, and the form rules follow the WHATWG URL Standard.

MethodCharacters left as they are
encodeURIComponentA-Z a-z 0-9 - _ . ! ~ * ' ( )
encodeURIThe same, plus ; , / ? : @ & = + $ #
RFC 3986 strictA-Z a-z 0-9 - _ . ~
Form (+ for spaces)A-Z a-z 0-9 - _ . *, and a space becomes +

Worked example

The default input is Crème brûlée & coffee: 5% off (today)!. With encodeURIComponent the tool shows:

Cr%C3%A8me%20br%C3%BBl%C3%A9e%20%26%20coffee%3A%205%25%20off%20(today)!

With RFC 3986 strict the parentheses and the exclamation mark are encoded too:

Cr%C3%A8me%20br%C3%BBl%C3%A9e%20%26%20coffee%3A%205%25%20off%20%28today%29%21

Limits and edge cases

Frequently asked questions

What is the difference between encodeURI and encodeURIComponent?

encodeURI is for a whole URL. It leaves characters that have a job in a URL, such as : / ? # & = and +, alone. encodeURIComponent encodes those too, so it is the right choice for one query value or path segment. Running encodeURI on a value that contains an ampersand leaves the ampersand in place and breaks the query string.

Should I use + or %20 for a space?

A plus sign means a space only in form data and query strings (application/x-www-form-urlencoded). In a path or fragment a space must be %20. Because %20 is also accepted in query strings, it is the safer default.

Why does my decoded text still contain plus signs?

A plus sign is only turned into a space for form data. Tick Treat + as a space (form data) when you decode a query string or form body. Leave it off for paths and for text that really contains plus signs, such as phone numbers or Base64.

Why does my URL show %2520 instead of %20?

The text was encoded twice. The first pass turned a space into %20, and the second pass turned the percent sign into %25. Decode it once more, or encode the original text only one time.

Related tools: Base64 encoder and decoder for binary data, the HTML entity encoder for text inside web pages, and the JSON formatter for API payloads.