एन्कोडिंग
HTML Entities Encode/Decode
HTML एंटिटीज़ एन्कोडिंग और डिकोडिंग — पेज पर स्पेशल कैरेक्टर्स को सुरक्षित रूप से दिखाना।
HTML entities are a way to write characters that would otherwise break markup (<, >, &) or have no keyboard key, as safe text sequences like < or &. This tool encodes and decodes such entities right in your browser.
How to use it
- Encode: paste text and characters like <, >, &, and quotes get replaced with their matching entities.
- Decode: paste HTML containing entities (&, ©, etc.) to see the plain text.
- Both named entities (&) and numeric ones (& or &) are supported.
Common uses
- Safely displaying user text (a comment, a message) on a page without risking broken markup or an injected script.
- Embedding HTML code samples in an article or documentation so the browser shows them as text instead of rendering them.
- Decoding content copied from another site where the characters arrived already entity-encoded.
Things to keep in mind
HTML entity escaping only protects against XSS via a page's text content — it does not protect a JavaScript context (innerHTML, eval) or href/src attributes containing unvalidated URLs.
Encode exactly at the point where text gets inserted into HTML, not ahead of time when saving to a database — otherwise the data gets mangled when reused outside an HTML context.
इस टूल के बारे में लेख: HTML Entities: विशेष वर्णों को सुरक्षित रूप से कैसे दिखाएँ
अक्सर पूछे जाने वाले प्रश्न
HTML एंटिटीज़ की ज़रूरत क्यों पड़ती है?
ब्राउज़र <, >, & जैसे कैरेक्टर्स को मार्कअप का हिस्सा मान लेता है, इसलिए इन्हें टेक्स्ट के तौर पर सुरक्षित दिखाने के लिए एंटिटीज़ में एन्कोड करना पड़ता है — इससे न मार्कअप टूटता है, न कोई XSS जैसा रिस्क बनता है।
नेम्ड और न्यूमेरिक एंटिटी में क्या फ़र्क़ है?
नेम्ड एंटिटी (जैसे &) पढ़ने में आसान होती है और सिर्फ़ कुछ जाने-पहचाने कैरेक्टर्स के लिए होती है, जबकि न्यूमेरिक (जैसे & या &) किसी भी यूनिकोड कैरेक्टर को उसके कोड पॉइंट से दर्शा सकती है, चाहे उसका कोई नाम हो या न हो।
क्या इनपुट टेक्स्ट कहीं अपलोड होता है?
नहीं, एन्कोडिंग और डिकोडिंग पूरी तरह ब्राउज़र में होती है, सर्वर पर कुछ नहीं भेजा जाता।
क्या एट्रिब्यूट के अंदर टेक्स्ट को पेज के बॉडी से अलग तरीके से एस्केप करना पड़ता है?
मुख्य कैरेक्टर्स (<, >, &) एक जैसे ही एस्केप होते हैं, लेकिन उद्धरण चिह्नों वाले एट्रिब्यूट के अंदर उसी टाइप के उद्धरण चिह्न को एस्केप करना बहुत ज़रूरी है, जिससे एट्रिब्यूट बंद किया गया है — वरना मान उम्मीद से पहले "टूट" जाएगा।
क्या HTML एस्केपिंग हर तरह के XSS से बचाता है?
नहीं। यह सबसे आम वेक्टर — HTML कंटेंट में टेक्स्ट डालने — को रोकता है, लेकिन JavaScript कॉन्टेक्स्ट के ज़रिए होने वाले XSS (जैसे innerHTML के बाद कोड चलना) या href/src में बिना जांचे URL से नहीं बचाता।