Guide

URL Encoding: encodeURIComponent vs encodeURI, %20 vs +

Short answer: URL encoding (percent-encoding) replaces characters that may not appear in a URL with % followed by their UTF-8 bytes in hex: a space becomes %20, and é becomes %C3%A9. Encode each value on its own with the component mode (JavaScript's encodeURIComponent), then join the pieces. Use the full URL mode (encodeURI) only on a complete address you want to keep working. The URL Encoder & Decoder does both and reports malformed input instead of guessing.

Why encoding exists

A URL can only contain a limited set of characters. Anything else, including spaces, accented letters, emoji, and characters that have a job in URL syntax (? & = # /), must be written as percent escapes. Otherwise the receiver cannot tell your data from the URL's own structure.

The characters that never need escaping are the unreserved ones from RFC 3986: letters, digits and - . _ ~. In a query value, everything else is escaped.

Component or full URL?

Mode Escapes JavaScript equivalent Use it for
Encode component everything except letters, digits and - _ . ! ~ * ' ( ) encodeURIComponent one query value or one path segment
Encode full URL only what cannot appear in a URL; keeps : / ? # & = encodeURI a whole address that already has its structure

A quick demonstration. Component mode turns

a b&c=d/é?x=1#t

into

a%20b%26c%3Dd%2F%C3%A9%3Fx%3D1%23t.

Full URL mode turns https://example.com/a b?q=café&x=1#top into https://example.com/a%20b?q=caf%C3%A9&x=1#top, leaving the structure intact.

The rule of thumb: encode each value on its own, then build the URL. If you run a complete URL through component mode, the :// and the ? are escaped too and the link stops working. In full-URL mode, characters such as ; , @ $ + stay as they are and square brackets become %5B and %5D.

Space: %20 or +?

%20 is always safe. The + sign means "space" only in form-encoded data, such as the query string an HTML form submits. In a URL path a plus is just a plus. The tool has a Use + for spaces option for form-style data: a b+c becomes a+b%2Bc, with the real plus escaped as %2B. The same option decodes + back into a space.

If a plus sign keeps turning into a space (or the other way round) somewhere in your pipeline, this is almost certainly why.

Double encoding

%2520 is an already-encoded %20: the % itself was encoded as %25. Decoding it once gives %20, and a second pass gives a space. If you see %25 in a URL, something encoded the text twice. The fix is to find the layer that encodes twice, not to decode more times.

Malformed sequences

A % that is not followed by two hex digits, as in %E0%A4%A, is reported as "Malformed URL-encoded text (check the % sequences)" rather than being guessed at. Silent guessing is how corrupted data ends up in a database, so a clear error is the better behaviour.

Non-ASCII text

Letters outside basic ASCII become their UTF-8 bytes. é is %C3%A9, and an emoji becomes four escaped bytes. If a name looks garbled after decoding, the sender probably used a different character set.

Encoding is not security

Percent-encoding only changes how characters are written, much as HTML entities do in HTML. Anyone can decode it, so it does not protect sensitive data, and it is not the same thing as Base64 (see Base64 is not encryption).

How to do URL encoding and decoding with the URL Encoder & Decoder

  1. Open the URL Encoder & Decoder.
  2. Choose Encode component, Encode full URL or Decode.
  3. Paste your text. Tick Use + for spaces only for form-style data.
  4. Copy the result (for requests built by hand, see building a curl command from the Network tab). To take a URL apart (host, path, query, fragment) instead, use the URL Parser.

Limits to know

  • The tool applies the standard rules. It cannot know which part of a URL your own application expects to be encoded.
  • It does not repair a broken URL. It reports problems.
  • Nothing is uploaded. Everything runs in your browser.

Frequently asked questions

What is the difference between encodeURI and encodeURIComponent? encodeURI keeps the characters that structure a URL. encodeURIComponent escapes them too, so it is for single values.

Is a space %20 or +? %20 always works. + means space only in form-encoded query strings.

What does %2520 mean? A double-encoded space: %20 whose % was encoded again.

Which characters never need encoding? Letters, digits and - . _ ~.

Does URL encoding protect sensitive data? No. It is reversible by anyone.

Related tools and guides

Sources and further reading