टेक्स्ट
String Escape
टेक्स्ट को स्ट्रिंग लिटरल में एस्केप करें (कोट्स, बैकस्लैश, कंट्रोल कैरेक्टर्स) ताकि कोड में पेस्ट किया जा सके, या वापस अनएस्केप करें।
To put text containing quotes, line breaks, or backslashes inside a string literal in code, those characters need escaping — otherwise they'll end the string early or get misinterpreted. This tool escapes and unescapes text for a specific syntax.
How to use it
- Escape: paste text and pick a target context (a JS string, JSON, shell, etc.) and special characters get replaced with the matching escape sequences.
- Unescape: paste an already-escaped string to get the original text back.
- Different contexts escape the same character differently — make sure you've picked the mode matching where the text will actually be inserted.
Common uses
- Inserting multi-line text or text with quotes into a code variable without manually placing backslashes.
- Preparing a string for a shell command, where quotes and special characters can break execution.
- Unescaping a string copied from logs or a JSON response to read the original text.
Things to keep in mind
The same character (a double quote, for example) is escaped differently depending on context — a JS string, JSON, and a shell each have their own syntax and their own set of special characters.
Double-escaping (escaping already-escaped text) is a common mistake when passing data through multiple layers, like JSON nested inside a shell command.
इस टूल के बारे में लेख: स्ट्रिंग एस्केपिंग: JS, JSON, शेल और रेगेक्स में अलग-अलग नियम क्यों
अक्सर पूछे जाने वाले प्रश्न
एस्केपिंग वास्तव में क्या करता है?
यह कोट्स, बैकस्लैशेस, और कंट्रोल कैरेक्टर्स (जैसे लाइन ब्रेक्स या टैब्स) को स्ट्रिंग लिटरल के भीतर वैध एस्केप सीक्वेंस में बदल देता है, ताकि टेक्स्ट को सोर्स कोड में जैसा है वैसा ही पेस्ट किया जा सके।
कोट स्टाइल और यूनिकोड विकल्प किस लिए हैं?
कोट स्टाइल (डबल, सिंगल, या बैकटिक) तय करता है कि कौन-सा कैरेक्टर एस्केप होगा ताकि स्ट्रिंग न टूटे, और \uXXXX विकल्प नॉन-ASCII कैरेक्टर्स को जैसा है वैसा छोड़ने के बजाय एस्केप्ड यूनिकोड सीक्वेंस में बदल देता है।
क्या पेस्ट किया गया टेक्स्ट सर्वर पर भेजा जाता है?
नहीं, एस्केपिंग और इसे पूर्ववत करना पूरी तरह ब्राउज़र में JavaScript के ज़रिए होता है, कोई डेटा ऑनलाइन नहीं भेजा जाता।
अगर टेक्स्ट लगातार कई संदर्भों से गुज़रता है तो क्या करें?
एस्केपिंग सही क्रम में करनी होगी: पहले भीतरी संदर्भ (जैसे JSON) के लिए, फिर बाहरी (जैसे वह शेल कमांड, जिसमें यह JSON डाला जाता है) के लिए। क्रम गड़बड़ होना या किसी एक लेवल को छोड़ देना, यही सबसे आम वजह है कि "सही ढंग से एस्केप की गई" स्ट्रिंग व्यवहार में फिर भी टूट जाती है।
एक ही कोट अलग-अलग संदर्भों में अलग तरह से एस्केप क्यों होता है?
हर संदर्भ (JS स्ट्रिंग, JSON, shell, regex) की अपनी सिंटैक्स होती है, जिसके अपने स्पेशल कैरेक्टर और उन्हें एस्केप करने का अपना तरीका होता है — इसलिए सही एस्केपिंग इस बात पर निर्भर करती है कि टेक्स्ट ठीक कहाँ डाला जा रहा है, टेक्स्ट पर नहीं।