URL encoder and decoder

Percent-encode text for URLs, or decode %-encoded links back into readable text. Handles UTF-8, form-style + spaces and broken sequences.

26 chars
43 chars

Break a URL into parts

Protocolhttps:
Hostexample.com
Path/search
Fragment#results
?qcafé au lait
?langfr
?page2

What gets encoded, and why

A URL may only contain a limited set of ASCII characters. Letters, digits and - _ . ~ are always safe. Characters such as ? & = # / are “reserved”: they give the URL its structure, so a literal & inside a search term must become %26 or the server will read it as the start of a new parameter.

Anything outside ASCII is first turned into UTF-8 bytes, and each byte is written as % plus two hex digits. That's why “é” becomes two escapes, %C3%A9: the same bytes the text to hex converter shows.

Questions people ask

What is URL encoding?

URL encoding (percent-encoding, RFC 3986) replaces characters that are not allowed or have special meaning in a URL with % followed by two hex digits of each UTF-8 byte. A space becomes %20, “é” becomes %C3%A9.

encodeURIComponent or encodeURI?

Use component mode (encodeURIComponent) for a single value you are putting into a query string or path segment: it also encodes / ? & = #. Use full-URL mode (encodeURI) on a complete URL when you only want to fix spaces and non-ASCII characters without breaking its structure.

Should a space be %20 or +?

Both appear. %20 is correct everywhere in a URL. + means space only in application/x-www-form-urlencoded data (HTML form submissions and most query strings). Choose “Form (+)” to produce +; the decoder treats + as a space by default.

How do I decode a URL?

Switch to Decode and paste it. Every %XX sequence is turned back into its byte, and the bytes are read as UTF-8. Invalid sequences are left in place rather than failing.

Why is my URL double-encoded (%2520)?

%25 is an encoded “%”. If you see %2520, a %20 was encoded a second time. Decode twice to recover the original.