URL Encoder & Decoder

Encode or decode URL strings. Converts special characters to percent-encoding and back. Free online URL encoder/decoder.

What is URL Encoder/Decoder?

A URL encoder converts special characters in text into percent-encoded format (e.g., space becomes %20, & becomes %26) so they can be safely included in URLs. URLs can only contain a limited set of ASCII characters — letters, numbers, and a few symbols. Any other characters (spaces, international characters, reserved symbols like &, =, ?, #) must be encoded to prevent them from being misinterpreted as URL structure. This tool encodes text for safe use in query parameters, path segments, and other URL components, and can decode percent-encoded URLs back to readable text.

How It Works

The encoder identifies characters that aren't URL-safe according to RFC 3986 and replaces each with a percent sign (%) followed by two hexadecimal digits representing the character's byte value. For Unicode characters (like emoji or non-Latin text), the text is first converted to UTF-8 bytes, then each byte is percent-encoded. The decoder reverses this process, converting percent-encoded sequences back to their original characters. The tool handles both encodeURIComponent (for query parameter values) and encodeURI (for full URLs where structural characters should remain) semantics.

Examples

Encoding a query parameter value
Input
https://example.com/search?q=coffee & cake
Output
https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dcoffee%20%26%20cake
(encodeURIComponent — encodes the structural characters too)
Non-ASCII becomes UTF-8 percent escapes
Input
café
Output
caf%C3%A9

Quick Reference

CharacterPercent-encodedMust encode in a query value?
space%20Yes (or + in form-encoded data)
&%26Yes - otherwise it starts a new parameter
=%3DYes - otherwise it splits key from value
?%3FYes in a path; optional inside a value
#%23Yes - everything after it becomes the fragment
+%2BYes - otherwise it may be read as a space
/%2FYes inside a value; leave alone in a path
- _ . ~not encodedNo - the RFC 3986 unreserved set

Common Use Cases

  • •Encoding query parameter values that contain special characters, spaces, or Unicode text
  • •Preparing search terms for use in URL query strings (?q=encoded+search+term)
  • •Encoding file paths with spaces or special characters for use in download URLs
  • •Debugging encoded URLs by decoding them back to readable form for inspection
  • •Preparing redirect URLs where the target URL needs to be passed as a parameter
  • •Encoding form data for application/x-www-form-urlencoded POST requests

Frequently Asked Questions

What is URL encoding?▼

URL encoding replaces unsafe characters with a % followed by two hex digits, making strings safe for URLs.

What is the difference between encodeURI and encodeURIComponent?▼

`encodeURI` is for a whole URL and deliberately leaves the structural characters `: / ? # [ ] @ & = + $ ,` alone. `encodeURIComponent` is for a single query parameter value and encodes those characters too. Using the wrong one is the classic cause of a parameter value silently breaking the URL structure.

Why does a space sometimes become %20 and sometimes a plus sign?▼

`%20` is correct in a URL path and is always safe. The plus sign means a space only in `application/x-www-form-urlencoded` data, which is how HTML form submissions and query strings are traditionally encoded. Because of that ambiguity, a literal plus in a value must be encoded as `%2B` or it will be read as a space.

Which characters are safe to leave unencoded?▼

The unreserved set from RFC 3986: the letters A to Z and a to z, the digits 0 to 9, and the four characters hyphen, underscore, period and tilde. Everything else should be percent-encoded when it appears inside a component.

How do I encode non-ASCII characters and emoji?▼

They are first converted to UTF-8 bytes, then each byte is percent-encoded. That is why one accented character becomes two escape sequences (é is `%C3%A9`) and a single emoji can become four. It also means encoded URLs get long quickly, which matters against practical URL length limits of around 2,000 characters.

Should the fragment after the hash be encoded?▼

The fragment is never sent to the server, but it still must be a valid URL component, so encode spaces and reserved characters within it. Note that a `#` inside a parameter value must always become `%23`, otherwise everything after it is treated as the fragment.

Further Reading

Related Tools

More from Developer Tools: