URL Encoder / Decoder

The URL Encoder / Decoder tool transforms URLs into a format suitable for safe transmission over the internet, encoding unsafe characters into their percent-encoded equivalents. Conversely, it decodes encoded URLs back to their original form, making it essential for web developers and anyone working with web addresses.

S. Siddiqui

Edited by

S. SiddiquiFounder & Editor-in-Chief
Sources:MDN Web DocsW3CIETFUpdated May 2026
Output appears here...

What Is the URL Encoder / Decoder?

The URL Encoder converts text into a percent-encoded format that is safe to include in a URL, and the decoder reverses that process. Percent-encoding replaces characters that have special meaning in URLs, such as spaces, ampersands, equals signs, and non-ASCII characters, with a percent sign followed by two hexadecimal digits representing the character's byte value. This encoding scheme is defined in RFC 3986, the standard for Uniform Resource Identifiers.

In practice, you come across the need for URL encoding constantly: when passing user input as a query parameter, when building API request URLs programmatically, and when dealing with URLs that contain non-ASCII characters from languages other than English. The MDN reference for encodeURIComponent covers the browser's built-in encoding function in detail.

How to Use the URL Encoder / Decoder

  1. Paste your text into the input field and select Encode to convert it to a percent-encoded URL-safe string.
  2. To decode, paste a percent-encoded string and select Decode to recover the original text.
  3. Choose between component encoding (encodeURIComponent behaviour) and full URI encoding (encodeURI behaviour). Component encoding is what you want for query parameter values. Full URI encoding is what you want for an entire URL that already has its structure in place.
  4. The output updates instantly. Use the copy button to take it from there.
  5. The tool also handles plus-sign encoding: some systems use + to represent spaces in query strings rather than %20. Toggle this option to match the format your target system expects.

Technical Background

RFC 3986 divides URL characters into two categories: reserved characters that have structural meaning in a URL (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) and unreserved characters that can appear literally (A-Z a-z 0-9 - _ . ~). Any other character, including spaces and non-ASCII Unicode characters, must be percent-encoded.

The encoding works by converting each character to its UTF-8 byte representation and then encoding each byte as %XX where XX is the uppercase hex value of the byte. For example, a space becomes %20, the copyright symbol © becomes %C2%A9 (its two UTF-8 bytes), and a Chinese character like becomes %E4%B8%AD (its three UTF-8 bytes).

What is more, there are two encoding levels to be aware of. encodeURIComponent encodes everything except unreserved characters, which is what you need for individual query parameter values. encodeURI also encodes non-ASCII characters but leaves reserved characters intact, because it is designed for encoding an already-structured URI rather than a component within it. Using the wrong one is a common source of bugs when building URLs in JavaScript.

Common Use Cases

  • Query string construction: When building a search URL like /search?q=user input dynamically, the input value must be encoded so that spaces and special characters do not break the URL structure.
  • API request building: REST APIs that accept parameters in the URL require those parameters to be percent-encoded. Tools and libraries usually do this automatically, but when building URLs manually you need to encode each value.
  • Redirect URLs: When passing a full URL as a query parameter value (for example in a returnUrl parameter), the entire URL must be encoded as a component so that its own ?, &, and = characters do not conflict with the outer URL's structure.
  • Debugging: When a URL is not working as expected, decoding the percent-encoded version here lets you see the actual values that were passed, which makes it easier to track down where an encoding issue crept in.

For encoding strings for other purposes, the Base64 Encoder covers binary-to-text encoding. The Regex Tester is useful if you need to write a pattern to validate or extract parts of a URL programmatically.

Limitations to Know

Given that URLs have different encoding rules for different components, a common mistake is applying the wrong level of encoding. Encoding an entire URL with encodeURIComponent will encode the slashes, colons, and query characters, producing a string that is no longer a functional URL. Use component encoding only for individual values within a URL, not for the URL as a whole.

That said, the plus-sign convention for spaces (+ instead of %20) is common in HTML form submissions but is not standard in RFC 3986. Whether a system interprets + as a space or as a literal plus sign depends on the context. If you are unsure which convention the target system expects, %20 is safer because it is unambiguous.

In practice, all modern JavaScript frameworks and HTTP client libraries handle URL encoding automatically. You only need to encode manually when constructing URLs with string concatenation, which is generally a pattern worth moving away from in favour of a URL object or a URLSearchParams instance.

Conclusion

The URL Encoder / Decoder handles the practical encoding and decoding tasks that come up whenever you work with URLs that contain user input, non-ASCII text, or special characters. It supports both component-level and URI-level encoding, handles the plus-sign space convention, and decodes percent-encoded strings back to readable text for debugging. The definitive reference for URL syntax and encoding rules is RFC 3986.

Last reviewed: May 31, 2026
Founder's Real-World Experience
S. Siddiqui

S. Siddiqui

Founder & Editor-in-Chief, YourToolsBase

How I fixed broken sitemap URLs caused by special characters in category names

When I was building the sitemap for YourToolsBase, I generated it programmatically from the database, pulling in all tool slugs and category paths. The sitemap validator came back with 14 malformed URL errors. I worked through the list and found that all of them belonged to categories whose names contained special characters: things like "C++ Tools", "Text & String", and "Health (BMI & Body)". The ampersands, parentheses, and plus signs had been dropped straight into the URL path without encoding.

I took each of the raw strings, ran them through this encoder, and compared the output against what was in the sitemap. As RFC 3986, the URI specification, makes clear, characters outside the unreserved set must be percent-encoded. The ampersand in "Text & String" was coming through as a literal & in the URL, which is a reserved character that query string parsers interpret as a parameter separator. As a result, the path was being parsed incorrectly by validators and some crawlers. The encoder showed me the correct encoded form for each string, which I then used to update the slug generation logic in the build script.

Given that the sitemap feeds both Google Search Console and the internal link structure, getting those URLs right was not optional. After the fix, all 14 errors cleared and the sitemap was accepted cleanly. What is more, I added the encoding step directly into the category slug generator so the same problem cannot come up again when new categories are added.

14 sitemap URL errors resolvedRFC 3986 compliant slugsEncoding built into slug generator permanently
Also used alongside: Base64 Encoder

Frequently Asked Questions

What is the difference between encodeURI and encodeURIComponent?
encodeURI is designed for encoding an entire URI. It leaves structural characters like /, :, ?, #, and & unencoded because they are part of the URL structure. encodeURIComponent is designed for encoding individual components, like a query parameter value. It encodes all reserved characters including / and ?, which is what you want when the value itself might contain those characters. For most use cases involving query parameters, encodeURIComponent is the correct choice.
Why does my URL break when it contains a plus sign?
The plus sign has an ambiguous role in URLs. In the application/x-www-form-urlencoded format used by HTML forms, + represents a space. But in general URI syntax per RFC 3986, + is a reserved character and must be percent-encoded as %2B if you want it treated as a literal plus sign. If you are seeing unexpected spaces in your decoded values, a + in the URL is being interpreted as a space. Encode your plus signs as %2B to avoid the ambiguity.
How are non-ASCII characters like Chinese or Arabic letters encoded?
Non-ASCII characters are first converted to their UTF-8 byte representation and then each byte is percent-encoded. For example, the Chinese character 中 is represented as three UTF-8 bytes (E4 B8 AD), which becomes %E4%B8%AD in a URL. This is defined in RFC 3986 as updated by RFC 3987 (Internationalized Resource Identifiers). Modern browsers handle this transparently, but when constructing URLs programmatically you need to apply the encoding explicitly.
Do I need to encode URLs by hand in JavaScript?
Not usually. The built-in URL object and URLSearchParams handle encoding automatically when you set properties or append parameters. For example, new URLSearchParams({q: 'hello world'}).toString() produces q=hello+world correctly. Manual encoding with encodeURIComponent is mainly needed when concatenating URLs as strings, which is generally an approach worth replacing with the URL or URLSearchParams APIs.
What characters do not need to be encoded in a URL?
RFC 3986 defines the unreserved characters as A-Z, a-z, 0-9, hyphen (-), underscore (_), period (.), and tilde (~). These can appear in any part of a URL without encoding. All other characters, including spaces, quotes, angle brackets, and non-ASCII characters, must be percent-encoded when used as data values within a URL component.
Why does decoding a URL sometimes produce garbled characters?
This usually happens when the original string was encoded using a character encoding other than UTF-8. Older systems sometimes used ISO-8859-1 (Latin-1) or other regional encodings. If you decode a percent-encoded string and see incorrect characters, the original may have been encoded in a non-UTF-8 encoding. There is no standard way to auto-detect the encoding, so you may need to try different decodings to find the correct one.

Formula

Rate This Tool

Was this tool helpful?

Be the first to rate this tool

💡 Pro Tip

Encode query parameter values, not the entire URL. Encoding the whole URL will break the slashes and colons that make it a valid URL.

About the Author

S. Siddiqui

S. Siddiqui

Founder & Editor-in-Chief

LinkedIn Profile

S. Siddiqui is the founder and editor-in-chief of YourToolsBase, overseeing all content, tool accuracy, and editorial standards.

View full profile

Authoritative Sources

Formulas and data in this tool are based on guidelines from the above sources.