Free Online URL Encoder & Decoder
Encode any text into a URL-safe format or decode percent-encoded strings back to readable text instantly. Choose betweenencodeURIComponent andencodeURIdepending on your use case. Everything runs in your browser โ your data never leaves your device.
What is URL Encoding?
URL encoding (also called percent-encoding) is a mechanism for encoding characters in a Uniform Resource Identifier (URI). It replaces unsafe or reserved ASCII characters with a%followed by two hexadecimal digits representing the character's byte value. For example, a space becomes %20 and an ampersand becomes %26.
URL encoding is defined in RFC 3986 and is essential for transmitting data in URLs because certain characters have special meaning in the URL syntax (such as &,=,?, and/). Without encoding, these characters would be interpreted as URL delimiters rather than literal values.
Common Percent-Encoded Characters
Here are commonly encoded characters and their percent-encoded representations:
| Character | Encoded | Description |
|---|---|---|
| %20 | Space | |
| & | %26 | Ampersand (query parameter separator) |
| = | %3D | Equals (key-value separator) |
| ? | %3F | Question mark (query string start) |
| / | %2F | Forward slash (path separator) |
| # | %23 | Hash (fragment identifier) |
| % | %25 | Percent sign (escape character) |
| + | %2B | Plus sign |
| @ | %40 | At sign |
| : | %3A | Colon (scheme separator) |
| ! | %21 | Exclamation mark |
| ' | %27 | Single quote / apostrophe |
| ( | %28 | Open parenthesis |
| ) | %29 | Close parenthesis |
encodeURI vs encodeURIComponent
JavaScript provides two built-in functions for URL encoding. They differ in which characters they encode:
| Feature | encodeURI | encodeURIComponent |
|---|---|---|
| Purpose | Encode a full URI | Encode a URI component (e.g., query value) |
| Encodes | Spaces, non-ASCII, some specials | Everything except A-Z a-z 0-9 - _ . ! ~ * ' ( ) |
| Preserves | : / ? # [ ] @ ! $ & ' ( ) * + , ; = - _ . ~ | Only unreserved chars |
| Use case | Encoding an entire URL string | Encoding query parameter keys/values |
| Example input | https://example.com/path?q=hello world | hello world&foo=bar |
| Example output | https://example.com/path?q=hello%20world | hello%20world%26foo%3Dbar |
Rule of thumb: UseencodeURIComponent for individual query parameter values and path segments. UseencodeURI when you need to encode an entire URL while preserving its structure.
Common Use Cases
Query Parameters
Encode user input before appending it to a URL query string so special characters don't break the URL structure.
Form Submissions
HTML forms with application/x-www-form-urlencoded content type percent-encode all field values before sending.
API Requests
Encode dynamic values in REST API endpoint URLs and query strings to ensure valid HTTP requests.
Redirect URLs
When passing a URL as a parameter (e.g., ?redirect=https://...), encode it so slashes and colons are preserved as data.
Email Links (mailto)
Encode subject lines and body text in mailto: links to handle spaces, ampersands, and special characters.
Internationalized URLs
Encode non-ASCII characters (accented letters, CJK, emoji) in URLs to comply with the URI specification.
Frequently Asked Questions
They are the same thing. URL encoding and percent-encoding both refer to the mechanism defined in RFC 3986 where unsafe characters are replaced with a percent sign (%) followed by two hexadecimal digits. The terms are used interchangeably.
Use encodeURIComponent when encoding individual query parameter values, path segments, or any fragment of a URL. Use encodeURI when encoding an entire URL string where you want to preserve the structural characters like ://?#&=. In most cases, encodeURIComponent is what you need.
Percent-encoding (%20) is the standard defined in RFC 3986 for encoding spaces in URIs. The plus sign (+) for spaces comes from the application/x-www-form-urlencoded format used in HTML form submissions. Both are valid in query strings, but %20 is the universal standard.
Yes. Everything runs entirely in your browser using JavaScript's built-in encodeURIComponent, encodeURI, decodeURIComponent, and decodeURI functions. Your text is never uploaded, transmitted, or stored on any server.
Yes. Non-ASCII characters like accented letters, CJK characters, and emoji are encoded as their UTF-8 byte sequences in percent-encoded form. For example, the emoji ๐ becomes %F0%9F%98%80 (its four UTF-8 bytes).
Unreserved characters that never need encoding are: A-Z, a-z, 0-9, hyphen (-), underscore (_), period (.), and tilde (~). All other characters may need encoding depending on where they appear in the URL.
Yes. Select 'encodeURI' from the method dropdown to encode a full URL while preserving its structural characters (://?#[]@!$&'()*+,;=). To encode everything including those characters, use 'encodeURIComponent' instead.
The tool will show an error message. Invalid sequences (like a lone % not followed by two hex digits, or invalid UTF-8 byte sequences) cannot be decoded and will be flagged as invalid input.