How to URL decode and URL encode
- URL decode: paste an encoded URL or fragment. If a
%is not followed by two hex digits, or the bytes are not valid UTF-8, the error says at which character. - URL encode: choose Component to encode a single value (like
encodeURIComponent) or Full URL to encode only what a complete address cannot contain (likeencodeURI). - Parse URL: see protocol, host, port, path, query and fragment separately, with every query parameter decoded in a table.
- If the decoded result still contains
%XXsequences, press Decode again: the URL was encoded twice.
Percent encoding rules (RFC 3986)
A URL may only contain a limited set of ASCII characters. RFC 3986, section 2 splits them into two groups:
- Unreserved:
A–Z a–z 0–9 - . _ ~. These never need encoding. - Reserved:
: / ? # [ ] @ ! $ & ' ( ) * + , ; =. They separate the parts of a URL, so they must be encoded when they appear inside a value.
Everything else, including spaces and all non-ASCII characters, is converted to UTF-8 bytes and each byte is written as % plus two hex digits:
| Character | Encoded |
|---|---|
| space | %20 (or + in form data) |
| & | %26 |
| = | %3D |
| / | %2F |
| ? | %3F |
| # | %23 |
| % | %25 |
| é | %C3%A9 |
| 😀 | %F0%9F%98%80 |
encodeURIComponent vs. encodeURI
JavaScript has two built-in encoders, and picking the wrong one is a common bug. encodeURIComponent is for a piece of a URL: it also encodes / ? & = #, so a value containing them cannot break the URL around it. encodeURI is for a whole URL that is already structured: it leaves those characters alone and only escapes spaces, non-ASCII text and a few others.
const q = 'fish & chips'
'https://example.com/?q=' + encodeURIComponent(q)
// → https://example.com/?q=fish%20%26%20chips ✔
encodeURI('https://example.com/?q=' + q)
// → https://example.com/?q=fish%20&%20chips ✘ "&" starts a new parameterWhen building query strings in code, URLSearchParams handles all of this for you (it uses the form encoding, with + for spaces). See the MDN reference for encodeURIComponent for the full list of characters each function leaves unescaped.
Plus signs, %20 and form data
In the path of a URL a space must be %20. In a query string submitted by an HTML form (the application/x-www-form-urlencoded format) a space is written as + and a literal plus as %2B. A strict URL decoder leaves + as it is, which is why this tool has a separate option for form data. If you decode a search URL and see words joined by plus signs, switch that option on.
Tokens and IDs inside URLs are often Base64URL rather than percent-encoded; the Base64 decoder reads those, and the JWT decoder splits a token from an ?id_token= parameter into its claims.