07 / Encoding / url-encoder
URL Encoder / Decoder
Percent-encode and decode URL components.
How to use
- 01Paste a full URL or a single value, such as a query parameter, into the Input editor.
- 02Leave Component mode on (the default) to encode a single value with encodeURIComponent, or turn it off to encode a whole URL with encodeURI.
- 03Press Encode to percent-encode the input, or Decode to reverse it. The result appears in Output.
- 04Copy the result. If decoding fails, an error notes that the input contains an invalid percent-encoding sequence.
- 05If the input is a complete URL, the Query parameters panel lists every key and its decoded value.
What is this tool?
Percent-encodes and decodes URLs and URL components with the browser's standard functions. Component mode uses encodeURIComponent and decodeURIComponent, and full-URL mode uses encodeURI and decodeURI. When the input is a complete URL, the tool also parses its query string into key and value pairs so you can see exactly what a request is carrying. Everything runs locally in your browser.
encodeURIComponent vs encodeURI
encodeURIComponent, used in Component mode, escapes every character that has special meaning in a URL, including : / ? # & = and +. Use it for a single piece of a URL, such as a query value, a path segment or a redirect URL passed as a parameter. encodeURI, used when Component mode is off, assumes the input is already a complete URL. It leaves those separators alone and only escapes characters that can never appear in a URL, such as spaces and non-ASCII text.
With the sample input https://example.com/search?q=dev tools&lang=en, full-URL mode gives https://example.com/search?q=dev%20tools&lang=en. Only the space changes. Component mode gives https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Ddev%20tools%26lang%3Den, which is correct only if the whole URL is being passed as a value inside another URL.
Why the wrong mode breaks query strings
Suppose a search value is Tom & Jerry. encodeURIComponent turns it into Tom%20%26%20Jerry, which is safe to place after q=. encodeURI turns it into Tom%20&%20Jerry and leaves the ampersand as it is, so the server reads q=Tom%20 and treats %20Jerry as a separate parameter. Non-ASCII text is converted to UTF-8 bytes in both modes, so café becomes caf%C3%A9.
Double encoding is the other common bug. Encoding a b once gives a%20b, and encoding it again gives a%2520b, because the % sign itself becomes %25. If you see %25 in a link, decode it one step at a time until the value reads correctly.
Plus signs, spaces and decoding errors
decodeURIComponent does not treat + as a space, so decoding a+b%20c gives a+b c. HTML form encoding and URLSearchParams do treat + as a space, which is why the Query parameters panel, which uses the browser's URL parser, shows q=a+b as a b. A value that seems to lose or gain spaces between your code and the server usually comes from this mismatch.
Decoding fails when the input has a % that is not followed by two hex digits, such as 100%, or a sequence that does not form valid UTF-8. Encode the stray % as %25 to fix it.
Common use cases
- Encoding query values and redirect_uri parameters for API and OAuth calls
- Debugging callback and redirect URLs that arrive mangled
- Reading UTM and other tracking parameters in a long link
- Finding and fixing double-encoded links that contain %25
- Preparing encoded test data for URL-handling edge cases
FAQ
What is the difference between encodeURI and encodeURIComponent?
encodeURI encodes a complete URL and keeps separators such as / ? & = and # intact. encodeURIComponent also escapes those separators, so it is the right choice for a single value placed inside a URL.
What is Component mode?
Component mode, which is on by default, uses encodeURIComponent and decodeURIComponent. Turn it off to use encodeURI and decodeURI for complete URLs.
How do I encode a space in a URL?
Both modes encode a space as %20. A + only means a space in form-encoded query strings, and decodeURIComponent leaves + unchanged.
Why does decoding fail with an invalid percent-encoding error?
The input contains a % that is not followed by two hex digits, or bytes that do not form valid UTF-8. A literal percent sign must be written as %25.
What does %25 mean in a URL?
It is an encoded percent sign. Sequences such as %2520 usually mean the value was encoded twice, so decode it again to recover the original.
When are query parameters shown?
Whenever the input is a complete, valid URL with a query string. Each key and its decoded value are listed, including repeated keys.
Is my URL sent anywhere?
No. Encoding, decoding and parsing all happen locally in your browser.