Encode/decode URL-formatted strings

What is an Url Encoder?

URLs may only contain a limited set of ASCII characters. Everything else, such as spaces, non-English letters and characters with special meaning like &, ?, # and /, must be percent-encoded: replaced by % followed by the hex value of each UTF-8 byte. This tool encodes text for safe use in URLs and decodes encoded strings back to readable text.

How to use it

  1. Paste text to encode it, or an encoded string to decode it.
  2. Copy the result.

Examples

  • hello world becomes hello%20world
  • a&b=c becomes a%26b%3Dc
  • café becomes caf%C3%A9 (é is two UTF-8 bytes)
  • %F0%9F%9A%80 decodes to 🚀

encodeURIComponent vs. encodeURI

  • encodeURIComponent encodes everything except letters, digits and - _ . ! ~ * ' ( ). Use it for individual query values and path segments.
  • encodeURI leaves URL structure characters like : / ? & = # intact. Use it only on a complete URL that just needs spaces and non-ASCII characters fixed.

Using encodeURI on a parameter value is a classic bug: an & inside the value is not encoded and splits the parameter.

Plus signs and spaces

In HTML form submissions (application/x-www-form-urlencoded), spaces are encoded as +. In other parts of a URL, + is a literal plus. If a decoded value has + where spaces should be, it was form-encoded.

Double encoding

If you see %2520, the value was encoded twice: %20 had its % encoded as %25. Encode exactly once, at the point where the URL is built.

Frequently Asked Questions

What is URL encoding?

Replacing characters that are not allowed or have special meaning in URLs with a percent sign followed by their hex byte values, such as %20 for a space.

Should I use encodeURI or encodeURIComponent?

Use encodeURIComponent for query parameter values and path segments. Use encodeURI only on a complete URL.

Why is a space sometimes a plus sign?

HTML form encoding represents spaces as plus signs in query strings. Elsewhere, a space is encoded as %20.

What does %2520 mean?

The text was encoded twice. %25 is the encoding of the percent sign, so %2520 is a double-encoded space.