Convert

Encode and decode URLs

Put a value into a URL safely, or read one that was already put there.

Encoding follows encodeURIComponent, which is the function for a value inside a query string or a path segment: unreserved characters stay as they are and everything that would end the value early — &, =, ?, #, / and a space — is escaped.

Decoding is decodeURIComponent. A % that is not followed by two hexadecimal digits is an error there, and it is reported as one rather than skipped, because silently ignoring it turns a broken link into a subtly different working one.

A literal plus stays a plus. Turning + into a space is a rule from HTML form submission, not from URLs, and a tool that does it without saying so corrupts base64 in query strings and arithmetic alike.

Questions

Should I use this for a whole URL?

No. Encoding a whole URL escapes its :// and / as well, which breaks it. Encode the value you are putting inside, not the address.

Why did + not become a space?

Because + means a space only in form-encoded bodies (application/x-www-form-urlencoded), not in a URL. The rule is stated on the page instead of being applied silently.

What do %20 and %2F mean?

%20 is a space and %2F is a slash: the escapes for characters that would otherwise change the structure of the URL.

Is the text uploaded?

No. Encoding and decoding are a function call in the page.

More text and code