URL Encoder/Decoder
Encode and decode URL components and full URLs.
About This Tool
Encode special characters in URLs using percent-encoding or decode percent-encoded strings back to readable text. Supports both full URL encoding (encodeURI) and component encoding (encodeURIComponent) for query parameters, path segments, and fragment identifiers. Essential for web developers building API requests, debugging query strings, and handling internationalized URLs with non-ASCII characters. All processing runs client-side in your browser.
What you provide
URL or text string to encode/decode
What you get
Encoded or decoded result
How to Use
- Paste your URL or text into the input area.
- Choose between full URL or component encoding mode.
- Click Encode or Decode, then Copy to copy the result.
URL Encoding in JavaScript
Use encodeURI() when encoding a complete URL you control. Use encodeURIComponent() when encoding a value that will be placed inside a query string parameter — it encodes & = # and other characters that encodeURI() intentionally leaves alone.
// encodeURI — encodes a full URL, preserves structural characters
const url = 'https://example.com/search?q=hello world&lang=en';
encodeURI(url);
// → 'https://example.com/search?q=hello%20world&lang=en'
// Note: & and = are preserved — they are valid URL structure
// encodeURIComponent — encodes a single value, escapes everything
const query = 'price=10&discount=5';
'https://example.com/redirect?url=' + encodeURIComponent(query);
// → 'https://example.com/redirect?url=price%3D10%26discount%3D5'
// Note: & and = are encoded — they are data, not structure here
// Decoding
decodeURIComponent('hello%20world%21');
// → 'hello world!'URL Encoding in Practice
URL encoding becomes critical the moment special characters enter your data. The most common failure point is query parameter values: if a redirect_uri, callback URL, or search query contains & or = characters and you use encodeURI() instead of encodeURIComponent(), those characters will be misinterpreted as parameter separators by the receiving server. OAuth 2.0 in particular requires strict percent-encoding of the redirect_uri parameter as defined in RFC 6749, and misencoding it is one of the most frequent causes of OAuth flow failures.
RFC 3986 defines three categories of characters in a URI: unreserved characters (A-Z, 0-9, hyphen, dot, underscore, tilde) which are never encoded; reserved characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) which have structural meaning and should only appear unencoded in their structural roles; and everything else which must be percent-encoded. In practice this means your encoding strategy depends on context: path segments, query values, and fragment identifiers each have different rules about which characters are safe to leave literal.
Common URL Encoding Bugs
- Double-encoding: running encodeURIComponent() on a string that is already encoded produces %2520 instead of %20 — always check whether your input is raw or pre-encoded.
- Encoding the # character inside a query parameter value — browsers split on # before parsing query strings, so an unencoded # truncates everything after it.
- Confusing space as + vs %20 — application/x-www-form-urlencoded (HTML forms) uses + for spaces, but RFC 3986 URLs require %20; mixing conventions breaks decoding.
- Using encodeURIComponent() on an entire URL — this encodes the :// and / characters, producing a broken result; use it only on individual values, not full URLs.
- Forgetting to encode non-ASCII characters before building URLs manually — always let the encoding functions handle UTF-8 conversion rather than doing it by hand.
Frequently Asked Questions
- What is URL encoding?
- URL encoding (percent-encoding) replaces unsafe characters with a % followed by their hexadecimal value. For example, a space becomes %20 and an ampersand becomes %26. This ensures URLs are transmitted correctly across the internet.
- What is the difference between URL and Component encoding?
- URL encoding (encodeURI) preserves characters that are valid in a full URL like :, /, ?, and #. Component encoding (encodeURIComponent) encodes everything except letters, digits, and - _ . ~, making it suitable for individual query parameter values.
- When should I use Component mode?
- Use Component mode when encoding a value that will be placed inside a query parameter. For example, if the value itself contains & or = characters, component encoding will escape them so they are not misinterpreted as parameter separators.
- Does this handle Unicode and international characters?
- Yes. The encoder correctly handles UTF-8 characters including accented letters, CJK characters, emojis, and other non-ASCII text. Each byte of the UTF-8 representation is percent-encoded individually.
- Is my data sent to a server?
- No. All encoding and decoding happens entirely in your browser using the built-in JavaScript encodeURI, encodeURIComponent, decodeURI, and decodeURIComponent functions. No data leaves your device.
Learn More
URL Encoding Explained: Percent-Encoding, RFC 3986, and Common Mistakes
Understand how URL percent-encoding works, the difference between encodeURI and encodeURIComponent, and how to avoid double-encoding bugs.
6 min read