Encode special characters into RFC 3986 percent-encoding and decode back live
Simultaneously encode and decode URLs and query string values in real time using standard UTF-8 percent-encoding (`encodeURIComponent` / `decodeURIComponent`).
URLs (Uniform Resource Locators, standardized under RFC 3986) can only be transmitted reliably across the internet using a limited subset of printable ASCII characters. Whenever a URL or query parameter contains spaces, non-ASCII Unicode characters (such as Hindi Devanagari text or emojis), or reserved syntax delimiters (`?`, `&`, `=`, `#`, `/`, `:`), those characters must be converted into 'percent-encoding'—where each UTF-8 byte is represented by a percent sign followed by two hexadecimal digits (for example, a space becomes `%20` and an ampersand `&` becomes `%26`). Our URL Encoder & Decoder processes your input instantaneously as you type, displaying both the `Encoded (RFC 3986)` output and the `Decoded` output side by side with one-click copy buttons.
Under the hood, this tool uses JavaScript's built-in `encodeURIComponent()` and `decodeURIComponent()` functions. Understanding how `encodeURIComponent()` behaves is vital for web developers: unlike `encodeURI()` (which leaves full-URL structural characters like `https://`, `/`, `?`, and `&` untouched), `encodeURIComponent()` encodes every reserved delimiter—turning `:` into `%3A`, `/` into `%2F`, `?` into `%3F`, and `=` into `%3D`—while leaving only unreserved characters (`A–Z`, `a–z`, `0–9`, `-`, `_`, `.`, `!`, `~`, `*`, `'`, `(`, `)`) unencoded. This makes `encodeURIComponent()` the safest choice when encoding an individual query parameter value (such as `?redirect=` or `?query=`) so embedded `&` or `=` symbols do not accidentally split your URL parameters.
When copying or debugging encoded strings, watch out for two common pitfalls. First, if you paste a complete URL (`https://example.com/page?q=hello`) into `encodeURIComponent()` and use the entire encoded result (`https%3A%2F%2Fexample.com...`) directly as an HTML `<a href="...">` link, browsers will treat it as a broken relative path because the `:` and `/` in `https://` were percent-encoded; only use full-URL component encoding when passing one URL inside another URL's query parameter. Second, if `decodeURIComponent()` encounters a bare `%` symbol that is not followed by two valid hexadecimal digits (like `50% off`) or an incomplete multi-byte UTF-8 sequence, the tool catches the `URIError: URI malformed` exception and displays a clear error message until the invalid `%` sequence is fixed.
इंटरनेट पर किसी भी वेब यूआरएल (URL - RFC 3986 मानक) को सुरक्षित रूप से भेजने के लिए केवल सीमित ASCII अक्षरों की ही अनुमति होती है। जब किसी यूआरएल या सर्च पैरामीटर में खाली जगह (Spaces), गैर-अंग्रेजी यूनिकोड अक्षर (जैसे हिंदी देवनागरी शब्द या इमोजी), या आरक्षित चिन्ह (`?`, `&`, `=`, `#`, `/`, `:`) आते हैं, तो उन्हें 'परसेंट-एनकोडिंग' (Percent-Encoding) में बदलना आवश्यक होता है—जिसमें प्रत्येक UTF-8 बाइट को `%` और दो हेक्साडेसिमल अंकों के रूप में लिखा जाता है (जैसे स्पेस `%20` बन जाता है और `&` का चिन्ह `%26` बन जाता है)। हमारा URL Encoder & Decoder आपके टाइप करते ही रियल-टाइम में काम करता है और एक ही स्क्रीन पर `Encoded (RFC 3986)` तथा `Decoded` दोनों परिणाम तुरंत दिखाता है।
तकनीकी रूप से यह टूल ब्राउज़र के मानक `encodeURIComponent()` और `decodeURIComponent()` फंक्शन का उपयोग करता है। डेवलपर्स के लिए यह समझना बहुत उपयोगी है कि `encodeURIComponent()` सामान्य `encodeURI()` से अलग कैसे काम करता है: जहाँ `encodeURI()` पूरे यूआरएल की संरचना बनाए रखने के लिए `:`, `/`, `?` और `&` को एनकोड नहीं करता, वहीं `encodeURIComponent()` सभी आरक्षित चिन्हों को भी एनकोड कर देता है (`:` को `%3A`, `/` को `%2F`, `?` को `%3F` और `=` को `%3D` में बदल देता है) और केवल सामान्य अक्षरों (`A–Z`, `a–z`, `0–9`, `-`, `_`, `.`, `!`, `~`, `*`, `'`, `(`, `)`) को ही बिना बदले छोड़ता है। इसलिए जब आपको किसी क्वेरी पैरामीटर के अंदर कोई वैल्यू या पूरा रीडायरेक्ट यूआरएल (`?redirect=...`) सुरक्षित रूप से भेजना हो, तो `encodeURIComponent()` सबसे सटीक तरीका है।
यूआरएल एनकोडिंग और डिकोडिंग के दौरान दो आम गलतियों से बचना चाहिए। पहली बात, यदि आप किसी पूरे यूआरएल (`https://example.com/search?q=test`) को एनकोड करके मिले परिणाम (`https%3A%2F%2F...`) को सीधे किसी वेबसाइट के `<a href="...">` लिंक में डाल देंगे, तो वह लिंक काम नहीं करेगा क्योंकि `https://` के कोलन और स्लैश भी एनकोड हो चुके होते हैं; पूरे यूआरएल को तभी एनकोड करें जब उसे किसी दूसरे यूआरएल के पैरामीटर के अंदर भेजना हो। दूसरी बात, यदि इनपुट टेक्स्ट में कोई ऐसा अकेला `%` चिन्ह मौजूद हो जिसके बाद दो वैध हेक्साडेसिमल अंक न हों (जैसे `100% free`), या कोई अधूरा UTF-8 कोड हो, तो डिकोड करते समय `Malformed URL: URIError` संदेश दिखाई देगा जिसे सही `%25` लिखकर ठीक किया जा सकता है।