Ad Space (header)

URL Encoder / Decoder

Encode and decode URLs and URL components with percent-encoding. 100% client-side.

Using encodeURIComponent()
Special Character Reference ▸
CharacterEncodedDescription
%20Space
!%21Exclamation
#%23Hash
$%24Dollar
&%26Ampersand
'%27Single quote
(%28Open paren
)%29Close paren
+%2BPlus
,%2CComma
/%2FSlash
:%3AColon
=%3DEquals
?%3FQuestion mark
@%40At sign

About This Tool

## Understanding URL Encoding

URL encoding, formally known as percent-encoding, is defined in RFC 3986. It ensures that URLs contain only valid ASCII characters by replacing unsafe characters with a % followed by their hexadecimal value.

### Reserved vs. Unreserved Characters

**Unreserved characters** (never encoded): A-Z, a-z, 0-9, - _ . ~

**Reserved characters** (encoded when used outside their special meaning): : / ? # [ ] @ ! $ & ' ( ) * + , ; =

### When to Use Each Function

Use `encodeURIComponent()` when encoding a value that will be placed in a query parameter, path segment, or fragment. Use `encodeURI()` only when encoding a complete URL string where you want to preserve the URL structure characters.

### Security Considerations

Always encode user-supplied data before inserting it into URLs to prevent URL injection and open redirect vulnerabilities. Double-encoding (encoding an already-encoded string) is a common mistake that leads to broken links.

Frequently Asked Questions

What is URL encoding?
URL encoding (percent-encoding) replaces unsafe or reserved characters in a URL with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII value. For example, a space becomes %20.
What is the difference between encodeURI and encodeURIComponent?
encodeURI() encodes a complete URL and preserves characters with special meaning (://?#&=). encodeURIComponent() encodes a single URL component (like a query parameter value) and encodes ALL special characters including those preserved by encodeURI.
When should I URL-encode data?
URL-encode data when building query parameters, form submissions, or any time user input is included in a URL. This prevents injection attacks and ensures special characters don't break the URL structure.
Why is + used for spaces in some URLs?
The + character for spaces comes from the application/x-www-form-urlencoded format used in HTML forms. In standard URL encoding (RFC 3986), spaces should be encoded as %20. Both are widely accepted by web servers.