URL Encoder & Decoder

Encode and decode URLs for safe web transmission.

📖 Learn the difference between %20 and +, and when to use encodeURIComponent — Understanding URL Encoding.

What is URL Encoding?

When you type a URL in your browser, certain characters have special meanings. A question mark starts the query string, an ampersand separates parameters, and spaces... well, spaces break everything. URL encoding solves this by converting these problematic characters into safe %XX codes.

For example, if you want to search for "rock & roll" on a website, the URL can't just have an ampersand sitting there - it would confuse the server. Instead, it becomes "rock%20%26%20roll" where %20 is a space and %26 is the ampersand.

Quick Reference

Space
becomes %20
&
becomes %26
=
becomes %3D
?
becomes %3F

Understanding URL Encoding

URL encoding (also called percent-encoding) converts characters that aren't allowed in URLs into a format that can be safely transmitted. URLs can only contain ASCII characters, so special characters, spaces, and international text must be encoded as %XX where XX is the hexadecimal representation of the character's byte value.

The difference between urlencode and rawurlencode is subtle: urlencode encodes spaces as '+' (legacy), while rawurlencode uses '%20' (RFC 3986 standard). Our tool uses standard encoding suitable for query parameters and general URL use.

Common Encoding Conversions

  • Space: %20 (or + in legacy encoding)
  • Ampersand (&): %26
  • Equals (=): %3D
  • Question mark (?): %3F

Frequently Asked Questions

Why do I need to encode URLs?

Characters like spaces, &, =, and ? have special meanings in URLs. Without encoding, a URL like "search?q=rock & roll" breaks because & starts a new parameter. Encoding makes it "search?q=rock%20%26%20roll" which is unambiguous.

When should I encode vs decode?

Encode when constructing URLs with user input or special characters. Decode when reading URL parameters to get the original values. Most web frameworks handle this automatically, but manual encoding is needed for API calls or custom URL construction.

Are there characters that don't need encoding?

Yes. Unreserved characters (A-Z, a-z, 0-9, -, _, ., ~) don't need encoding. Reserved characters (/, ?, #, &, =) should be encoded when used as data, but not when used for their intended purpose in URL structure.

What's the difference between encodeURI and encodeURIComponent?

encodeURI encodes a full URL but preserves characters with special URL meanings (like /, ?, and &). encodeURIComponent encodes everything, making it safe for query parameter values. Use encodeURIComponent for individual values and encodeURI for complete URLs.