Skip to content

URL Encoder & Decoder

Encode and decode URLs with the escape set that actually fits what you are doing. Picking the wrong one is the reason encoded links break, so all three are here and explained.

Runs in your browser · Files never uploaded
Direction
Escape set

encodeURIComponent — Escapes everything reserved, including : / ? # & = — use this for a single parameter value being inserted into a URL.

Converted on your device. Nothing is sent anywhere — which matters, since URLs frequently carry tokens and session identifiers.

How to use the URL encoder

  1. Choose a direction — encode or decode.
  2. Choose the escape set. This is the important step, and the explanation under each option says what it is for.
  3. Paste your input. Conversion happens as you type.
  4. Copy the result, or swap it back through in the other direction to check it round-trips.

Nothing is uploaded. Both directions use the browser's own built-in functions, on your device.

When you would need this

Building a link with a search term in it. Anything a user typed needs escaping before it goes into a query string, or a & in their input silently truncates your URL.

Reading a redirect chain. OAuth flows and tracking links nest encoded URLs inside other URLs, sometimes several deep. Decoding shows where you would actually end up.

Debugging an API request. A parameter that arrives wrong at the server is very often an encoding problem rather than a logic one.

Inspecting a suspicious link. Decoding a heavily-encoded URL before clicking shows the real destination.

Constructing a form submission by hand. Testing an endpoint with curl means encoding the body the way a browser would.

There is one error behind the majority of URL encoding problems, and it comes from reaching for the wrong function by default.

encodeURIComponent is the one most people know, and it escapes aggressively — including :, /, ?, #, & and =. That is exactly right for a value you are inserting into a URL, because those characters would otherwise be read as structure. Encode the search term cats & dogs and you get cats%20%26%20dogs, so the & becomes part of your value instead of starting a new parameter.

Apply the same function to a whole URL and you destroy it:

https://example.com/page?q=1
→ https%3A%2F%2Fexample.com%2Fpage%3Fq%3D1

Every character that made it a URL is now an escape sequence. It is a valid string, and it is no longer an address. Browsers treat it as a relative path or hand it to a search engine.

The rule is simple once stated: escape the parts, not the whole. Build your URL from an unescaped structure with escaped values inserted into it. If you already have a finished URL and only need it to survive transmission, use whole-URL encoding, which leaves the structure alone.

Why an accent becomes two escapes

Percent-encoding operates on bytes, not characters. Non-ASCII characters are first converted to UTF-8, then each byte is escaped separately.

So café becomes caf%C3%A9 — the é is two bytes in UTF-8, C3 and A9, and each gets its own escape. A Chinese character typically takes three bytes and produces three escapes; an emoji takes four.

This is why encoded URLs containing non-English text look so much longer than the original, and why counting characters in an encoded URL tells you very little about the text it represents.

It also explains a class of bug worth knowing: if a system decodes with the wrong assumed encoding, café comes back as café. That mangling — a single accented character becoming two odd ones — is the signature of a UTF-8 string being read as Latin-1 somewhere in the chain.

Encoding is not security

Percent-encoding is reversible with no key, exactly like Base64. It hides nothing.

It is worth knowing the reverse case though: encoding is sometimes used against you. A phishing link may percent-encode parts of a hostname or path so the destination is less obvious in a preview, or so a naive filter fails to match a blocklist. Decoding a suspicious link before clicking is a genuinely useful habit, and it is one of the more practical uses of a tool like this.

Limits and requirements

Decoding rejects malformed escapes. A % must be followed by two hexadecimal digits. Anything else reports an error rather than throwing or silently producing wrong output.

The + convention is query-string only. Form-data mode converts + back to a space when decoding. In a path segment, a + is a literal plus sign — decoding a path with form-data mode will corrupt it.

Double-encoded input needs two passes. %2520 is an encoded %20, which is itself an encoded space. Decoding once gives %20; decode again for the space. The swap button makes this quick.

Very long URLs. There is no limit here, but practical limits exist elsewhere — many servers reject URLs beyond about 8,000 characters, and some older software stops at 2,048.

Browser support. Any modern browser on desktop or mobile.

Privacy: how this tool handles your URLs

Encoding and decoding run in your browser using its own built-in functions. Nothing is transmitted, logged or stored.

URLs deserve more care than they usually get, because they carry more than an address. Password reset links contain single-use tokens that grant account access. OAuth callbacks carry authorisation codes. Plenty of APIs still accept keys as query parameters despite that being poor practice. Internal URLs reveal hostnames, service names and directory structures that describe how a system is built.

All of that ends up pasted into URL encoders routinely, and a server-side tool receives every character of it — where request URLs and bodies are logged by default at several layers.

You can verify the difference. Open your browser's developer tools, switch to the Network tab, and encode something: nothing carries your input. Or disconnect from the internet after the page loads and keep using it.

Frequently asked questions

What is the difference between the three escape sets?

They escape different characters. Query value (encodeURIComponent) escapes everything reserved, including : / ? # & and =, so the result is safe as a single parameter value. Whole URL (encodeURI) leaves that structure intact and escapes only genuinely unsafe characters like spaces, so a complete address survives. Form data is like query value except a space becomes + instead of %20, which is what an HTML form submits. Using the wrong one is the most common cause of a broken encoded link.

Which one should I use?

If you are inserting a single value into a URL — a search term, an ID, a redirect target — use query value. If you have a complete URL and just need to make it safe to transmit, use whole URL. If you are hand-building a form submission body, use form data. When in doubt, query value is the safer default: over-escaping a value is recoverable, under-escaping it breaks the URL structure.

Why does encoding a whole URL with the wrong setting destroy it?

Because query value encoding escapes the characters that give a URL its structure. Run https://example.com/page through it and you get https%3A%2F%2Fexample.com%2Fpage — a valid string, but no longer a URL. Browsers will treat it as a relative path or a search term. This is by far the most common mistake, and it happens because encodeURIComponent is the function people reach for by default.

Is %20 or + correct for a space?

Both, in different places. %20 is correct anywhere in a URL and always works. The + convention comes from application/x-www-form-urlencoded, the format HTML forms use, and is only valid inside a query string. A + in a path segment means a literal plus sign, not a space. If you are unsure, %20 is the safer choice because it means the same thing everywhere.

Why did my encoded link break when I pasted it into chat?

Messaging apps and email clients often try to detect where a URL ends, and percent-encoded characters confuse that detection. Trailing punctuation gets absorbed, or the link is cut short at an escaped character. This is not an encoding problem — the URL is correct — but it is a reason to prefer a short link for anything you are pasting into a message.

Does encoding a URL hide what it points to?

No. Percent-encoding is fully reversible with no key, exactly like Base64. Anyone can decode it, and browsers do so automatically. Encoded URLs are sometimes used in phishing to make a destination less obvious at a glance, which is a good reason to decode a suspicious link before clicking it — but it offers no protection to whoever encoded it.

Is my URL sent anywhere?

No. Encoding and decoding happen in your browser using its built-in functions. Nothing is transmitted or stored. This matters because URLs frequently carry more than an address — session tokens, password reset links, API keys in query parameters, and internal hostnames that reveal how a system is put together.

What characters actually need encoding?

Anything outside the unreserved set — letters, digits, hyphen, underscore, period and tilde — may need escaping depending on context. In practice the ones that matter are spaces, and the reserved characters : / ? # [ ] @ ! $ & ' ( ) * + , ; = which have structural meaning. Non-ASCII characters are encoded as their UTF-8 bytes, which is why an accented letter becomes two percent-escapes.

Written and maintained by Prashant ShekharLast updated