Advertisement

URL Encoder / Decoder

Advertisement

URL Encoding Explained

URL encoding (percent-encoding) replaces characters that aren't allowed in URLs with a % followed by their hexadecimal ASCII code. For example, a space becomes %20, "/" becomes %2F. This ensures URLs are transmitted correctly through all systems.

Characters That Must Be Encoded

encodeURI vs encodeURIComponent

Why do URLs sometimes use + instead of %20 for spaces?

The + sign as space replacement comes from HTML form encoding (application/x-www-form-urlencoded). When a browser submits a form via GET, spaces are encoded as + rather than %20. Most servers understand both, but %20 is the more universal standard (RFC 3986). In query strings + and %20 are usually interchangeable; in path segments, use %20 — a + in the path is treated as a literal plus sign.

How do I encode a full URL that already has query parameters?

Use encodeURIComponent() only on parameter values, not the entire URL. Encoding the whole URL breaks the URL structure by encoding ?, &, and =. The correct approach: build the URL structure normally, then encode each parameter value: `https://example.com/search?q=${encodeURIComponent(userInput)}`.