URL Encoder / Decoder

Encode and decode URLs using encodeURI or encodeURIComponent.

Encodes a complete URI. Does NOT encode: ; / ? : @ & = + $ , #

0 characters

Encoding comparison

Input:https://example.com/path?name=John Doe&city=New York
encodeURI():https://example.com/path?name=John%20Doe&city=New%20York
encodeURIComponent():https%3A%2F%2Fexample.com%2Fpath%3Fname%3DJohn%20Doe%26city%3DNew%20York

Use encodeURI() for:

  • • Full URLs with path and query
  • • When you want to keep ? & = # intact
  • • Encoding spaces and non-ASCII characters

Use encodeURIComponent() for:

  • • Query parameter values
  • • Form data
  • • Any text that will be part of a URL

Common URL encodings

CharacterEncodedDescription
(space)%20Space character
&%26Ampersand
=%3DEquals sign
?%3FQuestion mark
/%2FForward slash
@%40At symbol

Frequently Asked Questions

What's the difference between encodeURI and encodeURIComponent?

encodeURI() is for encoding complete URLs — it leaves characters like ; / ? : @ & = + $ , # intact. encodeURIComponent() encodes ALL special characters and is used for encoding individual URL parameters.

When should I use encodeURIComponent?

Use encodeURIComponent() when encoding query parameter values. For example, if a user enters "John & Jane" as a name, you need encodeURIComponent to properly encode the & character.

Why do spaces become %20?

Spaces are not allowed in URLs per RFC 3986. %20 is the percent-encoded representation of a space character (ASCII 32). Some systems also accept + for spaces, but %20 is more universally compatible.

What characters need to be encoded?

Any character outside the "unreserved" set (A-Z, a-z, 0-9, - _ . ~) should be percent-encoded. This includes spaces, non-ASCII characters, and reserved characters when used in data.

Is my data secure?

Yes. All encoding and decoding happens entirely in your browser using JavaScript. Your data is never sent to any server.

Related Tools