URL Encoder/Decoder
About the URL Encoder/Decoder
This URL encoder and decoder percent-encodes text for use in URLs and decodes %20-style sequences back into readable characters. Choose Component mode for a single query value or Full URL mode for a whole address, and paste any complete URL to see its host, path and every query parameter broken out.
What is URL encoding (percent-encoding)?
URLs may only contain a limited set of ASCII characters. Anything else, including spaces, non-English letters and characters that have a structural meaning, is converted to UTF-8 bytes and written as % followed by two hex digits. A space becomes %20 and é becomes %C3%A9.
Decoding reverses the process. A % that is not followed by two hex digits is malformed, and the decoder points to its exact position; a literal percent sign has to be written as %25.
encodeURIComponent vs encodeURI
Component mode uses encodeURIComponent, which escapes everything except letters, digits and - _ . ! ~ * ' ( ). That includes / ? & = #, so it is the right choice for one query value or path segment. a b&c=d/é becomes a%20b%26c%3Dd%2F%C3%A9.
Full URL mode uses encodeURI, which leaves the characters that give a URL its structure untouched. https://ex.com/a b?q=x&y=é#top becomes https://ex.com/a%20b?q=x&y=%C3%A9#top. Running a whole URL through Component mode would break it, because :// and ? would be escaped too.
Spaces: %20 or +?
In a URL path a space must be %20. HTML forms submitted as application/x-www-form-urlencoded use + for spaces in the query string instead, so hello world is sent as hello+world.
Turn on "Space as + (form encoding)" to produce or read that style. When decoding with it off, a + stays a literal plus sign, which is a common source of bugs when a server and client disagree.
How to Use the URL Encoder/Decoder
- Choose Encode or Decode, then pick Component for a single value or path segment, or Full URL to keep : / ? & = # intact. Turn on "Space as + (form encoding)" for HTML form data.
- Type or paste into the input panel, or click the Load Example icon to fill in a sample URL. The result appears on the other side immediately, and a full URL also gets a URL Breakdown card with its host, path and decoded query parameters.
- Use the Copy or Download icon on the result panel to take the output. Swap moves the result into the input and flips the mode, a quick round-trip check, and the trash icon clears the input.
URL Encoder/Decoder Examples
Encode one query value
Encode, Component, "+" off. &, = and / are escaped so the value cannot break the query string.
Input:
a b&c=d/é
Output:
a%20b%26c%3Dd%2F%C3%A9
Clean up a whole URL
Encode, Full URL, "+" off. The structure characters are kept; only the space and the accented letter are escaped.
Input:
https://ex.com/a b?q=x&y=é#top
Output:
https://ex.com/a%20b?q=x&y=%C3%A9#top
Decode a form-encoded value
Decode, Component, "Space as +" on.
Input:
hello+world%21
Output:
hello world!
Common Errors
- Malformed escape "%" at position N: "%" must be followed by two hex digits
- The text has a bare percent sign, such as 100%. Write a literal percent as %25, or encode the text first instead of decoding it.
- Invalid percent-encoded UTF-8 byte sequence
- A multi-byte character was cut off, for example %E2%82 without its last byte. Copy the full escaped sequence.
- Decoded text still contains %20 (or %2520 became %20)
- The value was encoded twice. Decode it a second time, then fix the code so it encodes only once.
- Full URL mode leaves %2F and %3F as they are when decoding
- Full URL decoding keeps escapes for structure characters such as / ? & = #. Switch to Component to decode every escape.
- Encoding a whole URL in Component mode gives https%3A%2F%2F...
- Component mode escapes : and / too. Use Full URL mode for a complete address and Component only for individual values.
Frequently Asked Questions
- Is the URL I paste sent anywhere?
- No. Encoding, decoding and the URL breakdown all run in your browser using built-in JavaScript functions.
- Why does %2520 appear in my URL?
- The value was encoded twice: %20 was encoded again and its % became %25. Decode it twice, then fix the code so it encodes only once.
- Which characters never need encoding?
- Letters A-Z a-z, digits and - _ . ~ are always safe. encodeURIComponent also leaves ! * ' ( ) unescaped.
- Should I encode the whole URL or just the parameters?
- Encode each parameter value separately with Component mode, then join them. Use Full URL mode only to clean up a complete URL that contains spaces or non-ASCII characters.
- Why do I get "Invalid percent-encoded UTF-8 byte sequence"?
- The input contains percent escapes that do not form valid UTF-8, often a multi-byte character that was cut off, such as %E2%82 without its final byte.