URL Encoder & Decoder
Percent-encode URLs, with separate modes for full URLs and parameter values
What is URL Encoder & Decoder?
A URL encoder that converts strings to percent-encoding and distinguishes two very different jobs: encoding a whole URL, which preserves structural characters such as : / ? and &, versus encoding a single query parameter value, which escapes those characters too. Both modes run in the browser.
How to use URL Encoder & Decoder
- 1Paste the URL or parameter value you need to process.
- 2Choose a mode: whole-URL encoding (encodeURI) or component encoding (encodeURIComponent).
- 3Switch to the decode direction to reverse percent-encoding.
- 4If %25 shows up in the output, the input was already encoded once — watch out for double encoding.
How do I do this in code?
Use the tool above for one-off work; for anything you repeat, move it into a script or your project.
// Whole URL: keeps structural characters such as : / ? & = #
encodeURI('https://a.com/搜索?q=你好');
// A single value: escapes & and = as well
encodeURIComponent('a&b=c');Common errors and how to fix them
| Symptom | Cause | Fix |
|---|---|---|
| An & inside a value splits one parameter into two | The value was encoded with encodeURI, which leaves & untouched. | Always encode parameter values with encodeURIComponent. |
| Decoded output still contains leftovers like %2520 | The input was encoded twice (double encoding). | Decode twice, then find and remove the duplicate call to the encoding function in your code. |
Frequently asked questions
When should I use encodeURI instead of encodeURIComponent?+
Use encodeURI when you are encoding a complete URL, since it preserves the structural characters : / ? & = and #. Use encodeURIComponent when you are inserting a value into a query parameter or a path segment, because it escapes those characters too and stops an & inside the value from breaking the parameter structure.
Should a space be encoded as %20 or +?+
Use %20 in URL paths and query strings — that is the standard. The + form belongs to application/x-www-form-urlencoded form submissions. The two are not interchangeable: drop a form-style + into a path and it is read as a literal plus sign.
Related tools
All toolsBase64 Encoder & Decoder
Encode and decode Base64, with UTF-8 and URL-safe support
File to Base64
Convert files to Base64 and data URIs — nothing is uploaded
HTML Entity Encoder
Escape and unescape HTML entities
Hex to Text Converter
Convert between text and hex with several separator styles
Unicode Escape Converter
Escape and unescape Unicode in three notations
Hash Generator
Compute SHA-1/256/384/512 and MD5 digests