ToolBench

Web

URL Encoder & Decoder

The two functions are not interchangeable. encodeURI keeps :/?#&= intact for a whole URL; encodeURIComponent escapes them for a single parameter value.

Result appears here.

How to use it

  1. Paste a URL or a single parameter value.
  2. Use encodeURI for a complete URL, encodeURIComponent for one value inside a query string.
  3. Use Decode to turn %20 and %E4%B8%AD back into readable text.

encodeURI versus encodeURIComponent

encodeURI leaves reserved characters such as / ? & = alone, so it is for encoding a whole URL that is already structurally correct. encodeURIComponent escapes those as well, so it is for encoding a single value that will be placed inside a query string or path segment. Using the wrong one is the usual reason a parameter silently breaks the structure of the URL around it.

Space: plus or %20?

In a query string, + has historically meant space — a convention inherited from HTML form submission. In a path segment, + is a literal plus and a space must be written %20. Many servers accept both, which is exactly why the bug survives testing and appears only against a strict implementation.

Encoding one parameter, not the whole URL

The common mistake is pasting an entire URL into the encoder. The result encodes the colons and slashes too, and every server will treat it as a single opaque path segment. Encode the value only, then assemble: /search?q= plus the encoded value.

The plus sign is the other trap. In a query string, + means a space under the form-encoding rules, so a literal plus must be sent as %2B. In a path segment, + is just a plus. A search for "C++" breaks on any backend that applies the query-string rule everywhere, which is most of them.

Frequently asked questions

What is the difference between %20 and +?

%20 is the percent-encoding of a space anywhere in a URL. The plus sign means space only in form-encoded bodies.

Why does my Chinese text become a long percent string?

Each UTF-8 byte becomes %XX, and a Chinese character takes three bytes — nine characters of encoding. That is normal.

Should I encode a slash inside a path?

No. A slash is a path separator; %2F changes its meaning to a literal slash inside one segment, which many servers reject.

Do I need to encode a URL before putting it in a QR code?

No. Encode only the parameters. A fully encoded URL still scans, but the destination sees one meaningless path instead of a route.

Why do Chinese characters become %E4%B8%AD?

Each character is three UTF-8 bytes, and each byte becomes one %XX triplet. That is why a short Chinese query looks so long once encoded.