navaja.dev / url

URL encode and decode

Percent-encode text for a URL, or decode %20-style escapes back to text. Paste a full URL to see its host, path and every query parameter decoded. Everything runs in your browser.

How to URL encode or decode

  1. To encode, type or paste text on the left. The percent-encoded version appears on the right, ready to put in a link or a query string.
  2. To decode, paste encoded text such as caf%C3%A9%20au%20lait on the right. The readable text appears on the left.
  3. To inspect a URL, paste it on the left. Its scheme, host, port, path, fragment and every query parameter are listed below, decoded.

Which encoding mode?

What percent-encoding is

URLs may only contain a limited set of ASCII characters. Anything else is written as UTF-8 bytes, each as % plus two hex digits: a space is %20, é is %C3%A9, and an emoji takes four escapes. Characters that have a meaning in URLs, such as & and =, must also be escaped when they are part of a value.

Common problems

URL encoding in code

Questions

What is the difference between encodeURI and encodeURIComponent?

encodeURI is for a whole URL and leaves the characters that structure it (: / ? # & =) alone. encodeURIComponent is for one piece, such as a query value, and encodes those characters too, so a value containing & or = can't break the URL.

Should a space be %20 or +?

Both are correct in different places. %20 works everywhere. + means a space only in form-encoded query strings and POST bodies (application/x-www-form-urlencoded). In a path, + is a literal plus sign.

Why does decoding fail with "URI malformed"?

The text has a % that isn't followed by two hex digits, or escapes that aren't valid UTF-8, for example %E9 from an old Latin-1 system. This tool keeps stray % signs and points at the bad escape instead of failing.

What does %2520 mean?

It is a double-encoded space: %25 is the encoding of % itself, so %2520 decodes to %20, which decodes to a space. Use Decode again to undo both layers.

Which characters never need encoding?

Letters A–Z and a–z, digits 0–9, and - _ . ~ are unreserved in RFC 3986 and are never encoded. Everything else may need encoding depending on where it appears in the URL.

Is my data sent anywhere?

No. Encoding, decoding and URL parsing all run in your browser, so tokens or private URLs you paste are never uploaded.