Encode/decode URL-formatted strings
Encode text to URL-encoded format (also known as "percent-encoded"), or decode from it.
About Encode/decode URL-formatted strings
URLs may only contain a limited set of characters, so anything else, such as spaces, non-Latin text or reserved symbols, is written as percent-encoding (a % followed by two hex digits). This tool encodes text that way and decodes it again, using the same rules as JavaScript's encodeURIComponent.
When you would use it
- Building a query-string value that contains spaces, &, = or non-English characters.
- Decoding a long %E4%B8%AD%E6%96%87-style string from a log or browser address bar to read it.
- Preparing a redirect target or callback URL that is passed inside another URL.
How to use it
- Type or paste text in the encode field to get the percent-encoded form.
- Paste an encoded string in the decode field to get the original text.
- Copy the result with the copy button.
Things worth knowing
- The encoder escapes every character except letters, digits and - _ . ! ~ * ' ( ). That includes / ? & = : #, so do not encode a whole URL, only the individual value you are inserting into it. Otherwise the URL stops working.
- A space becomes %20, not +. The + sign means a space only in HTML form submissions, so decoding a form-encoded string leaves the + signs in place.
- Non-ASCII characters are first converted to UTF-8 bytes, so one Chinese character becomes three %XX groups.
- Decoding fails on a % that is not followed by two hex digits, or on bytes that are not valid UTF-8.
Frequently asked questions
- Should I encode the whole URL or just the parameter values?
- Only the values (and key names, if needed). Encoding the whole URL also escapes the :// and the / separators and produces a string that is no longer a usable address.
- Why is a plus sign not decoded back to a space?
- Percent-decoding does not treat + specially. If the text came from a form submission (application/x-www-form-urlencoded), replace + with a space before decoding.