URL Encoder and Decoder
Percent-encode and decode URLs, and take a URL apart parameter by parameter.
Encoding and decoding are done in this page. Nothing you paste is sent anywhere, including the URLs you inspect.
A URL can only contain a limited set of characters, and a handful of those characters mean something structural: the slash separates path segments, the question mark starts the query, the ampersand separates parameters. Percent-encoding is how everything else gets in — a space becomes %20, an accented letter becomes the escapes for its UTF-8 bytes.
More about URL Encoder and Decoder
The question that brings most people here is which of the two encoding functions to use, and the answer is genuinely not obvious from their names. `encodeURIComponent` escapes the structural characters as well, so it is the right choice for one value going into a URL. `encodeURI` leaves them alone, so it is the right choice for an entire URL that just needs its spaces and accents cleaned up. Both are offered here, side by side, with the difference spelled out rather than assumed.
Using the wrong one is a quiet failure. Encode a search term with `encodeURI` and a `&` inside it survives, so `q=Marks & Spencer` arrives at the server as a parameter `q` with the value `Marks ` and a second, meaningless parameter. Nothing errors; the results are just wrong.
There is a second trap in decoding. HTML forms encode a space as `+`, while the rest of a URL encodes it as `%20`. Read `+` as a space in a path segment and you corrupt a filename; read it literally in a query string and a search for "hello world" comes back as "hello+world". This tool asks which you meant instead of guessing, because either guess is wrong half the time.
The inspect mode goes further and takes a whole URL apart: scheme, host, port, path, each query parameter as its own row, and the fragment. Repeated parameters stay separate, an internationalised domain is shown both as Punycode and as the letters you recognise, and editing any row rebuilds the URL with everything escaped correctly.
- Both encoding levels side by side, with the difference explained
- Decodes with a clear choice about whether + means a space
- Optional strict mode that also escapes ! ' ( ) * as RFC 3986 requires
- Reports a malformed escape with its position instead of failing silently
- Takes a URL apart into scheme, host, path, parameters and fragment
- Keeps repeated parameters separate rather than collapsing them
- Shows an international domain as both Punycode and readable letters
- Rebuilds the URL as you edit, escaping each part correctly
How to use it
- 1Paste your text or URL into the input.
- 2Choose the direction and level: encode or decode, one component or a whole URL.
- 3If you are decoding a query string or form data, turn on "read + as a space".
- 4Copy the result, or use the swap button to feed it straight back in.
- 5To pick a URL apart instead, switch to "Inspect a URL" and edit the parameter rows.
Questions
What is the difference between encodeURI and encodeURIComponent?
`encodeURIComponent` escapes the reserved characters too — colon, slash, question mark, hash, ampersand and equals — so it is the right choice for a single value you are putting into a URL. `encodeURI` preserves them, making it the one for a complete URL that only needs its spaces and accents escaped.
Should a space be %20 or +?
In a path, always %20; in a query string both are accepted and servers usually treat + as a space, a legacy of HTML form encoding. Use %20 when you are unsure, because it is correct everywhere.
Why did my encoded URL stop working?
Usually because it was encoded twice: a `%` that was already part of an escape gets encoded again as `%25`, so `%20` becomes `%2520`. Decode once and check whether you get readable text before encoding.
What are the strict-mode characters for?
RFC 3986 reserves the exclamation mark, apostrophe, brackets and asterisk, but the built-in JavaScript function follows an older spec and leaves them alone. Turn strict mode on when you are signing an OAuth request or talking to a server that rejects them.
Why does my Vietnamese domain look like xn--something?
That is Punycode, the ASCII form DNS actually uses for international domains. It is the same domain; the inspect view shows both so you can confirm the conversion is the one you expect.