XML फॉर्मेटर

XML को तुरंत फ़ॉर्मेट, सुंदर या मिनीफ़ाई करने के लिए पेस्ट करें।

कोई डेटा आपके डिवाइस से नहीं जाता

कैसे उपयोग करें

  1. अपना XML इनपुट क्षेत्र में पेस्ट करें
  2. सुंदर करने के लिए फ़ॉर्मेट पर या कंप्रेस करने के लिए मिनिफ़ाई पर क्लिक करें।
  3. परिणाम कॉपी या डाउनलोड करें।

अक्सर पूछे जाने वाले प्रश्न

यदि मेरे XML में त्रुटियाँ हैं तो क्या होगा?

टूल आपके XML को ब्राउज़र के अंतर्निहित DOMParser के साथ सत्यापित करता है। सिंटैक्स त्रुटियाँ आउटपुट के ऊपर एक लाल बॉक्स में प्रदर्शित होती हैं।

क्या यह CDATA अनुभाग, टिप्पणियाँ और प्रोसेसिंग निर्देश समर्थित करता है?

हाँ। फ़ॉर्मेटर सभी XML नोड प्रकारों को संरक्षित करता है, जिनमें CDATA अनुभाग, टिप्पणियाँ और प्रोसेसिंग निर्देश शामिल हैं।

क्या कोई आकार सीमा है?

कोई कठोर सीमा नहीं है · यह आपके ब्राउज़र की मेमोरी पर निर्भर करता है। कई MB की XML फ़ाइलें आमतौर पर तुरंत फ़ॉर्मेट होती हैं।

XML का Practical Tour

XML 1.0 10 February 1998 को W3C Recommendation बना, Tim Bray, Jean Paoli, और C. M. Sperberg-McQueen द्वारा edited, Sun के Jon Bosak की chair वाले working group के साथ। Tim Bray का launch quote design intent capture करता है: «XML is extensible, internationalized, robust, simple, and built for the Web.» Current canonical version Fifth Edition है, 26 November 2008 को published, Bray, Paoli, Sperberg-McQueen, Eve Maler और François Yergeau द्वारा edited। XML directly SGML (ISO 8879:1986) से descend करता है, एक much larger, much harder-to-implement document format जिससे XML ने seldom-used parts strip करते हुए document model intact रखा।

2026 में XML अभी भी कहां है

JSON ने एक decade से REST API payloads dominate किए हैं, लेकिन XML हर जगह entrenched रहता है जहां schema rigour, document semantics, या established standards इसे lock करते हैं। यह जानना कि किसी दिन आप इसे कहां मिलेंगे, एक good formatter का आधा value है:

Well-Formed vs Valid: ये Same Thing नहीं हैं

XML दो different conformance levels use करता है और ये confuse करने में आसान हैं:

यह formatter केवल well-formedness check करता है। Browser का built-in DOMParser red error box में surface करने वाले parsererror element के माध्यम से पहली parse error report करता है। Schema के विरुद्ध validation के लिए different tool चाहिए (XSD के लिए Saxon, xmllint --schema के साथ libxml2, W3C validator service, etc.)।

पांच Predefined Entity References

W3C XML 1.0 §4.6 के per, «well-formed documents need not declare any of the following entities»: amp, lt, gt, apos, quot। Trailing semicolon mandatory है, XML, कुछ HTML usage के unlike, &amp को closing ; के बिना कभी accept नहीं करेगा।

EntityCharacterकहां Required है
&lt;<हमेशा element content में (अन्यथा यह एक tag शुरू कर देगा)
&amp;&हमेशा (अन्यथा यह entity reference शुरू कर देगा)
&gt;>Content में ]]> sequence के अंदर required; symmetry के लिए अन्यत्र recommended
&apos;'Single quotes से delimited attribute values के अंदर
&quot;"Double quotes से delimited attribute values के अंदर

CDATA Sections, Comments, और Processing Instructions

तीन special syntactic features जिनका सामना XML format करने वाला कोई भी eventually करता है:

Namespaces

XML का namespace mechanism वह है जो multiple vocabularies को single document में coexist करने देता है, Atom plus custom extension, SOAP plus WS-Security headers, OOXML का main document part sister namespaces से relationships, drawings, और pictures reference करते हुए। Syntax है default namespace के लिए xmlns="…" और prefixed के लिए xmlns:prefix="…", और formatter दोनों को unchanged preserve करता है। Namespace URIs identifiers हैं, URLs नहीं, उन्हें किसी चीज़ resolve करने की ज़रूरत नहीं।

दो प्रसिद्ध XML सुरक्षा खतरे

The Billion Laughs attack। Recursively expanding entities वाली small XML file parser की memory में billions of characters तक balloon हो सकती है:

<!ENTITY lol "lol">
<!ENTITY lol2 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!-- … nine more layers later, the document expands to 10^9 lols -->

Modern parsers इसे defeat करने के लिए entity expansion cap करते हैं। XXE (XML External Entity) attacks ऐसे parser को exploit करते हैं जो external entities resolve करके local files पढ़ता है (<!ENTITY xxe SYSTEM "file:///etc/passwd">) या server से SSRF requests trigger करता है। OWASP का XXE prevention cheat sheet unambiguous है: «the safest way to prevent XXE is always to disable DTDs (External Entities) completely.» Exactly यही browser का DOMParser करता है, यह DOCTYPE entity declarations entirely ignore करता है, यही कारण है कि यह client-side formatter untrusted XML feed करने के लिए भी safe है।

Pretty-Printing बनाम Minifying

xml:space attribute आपका escape hatch है जब whitespace genuinely matter करता है, जैसे documentation में verbatim source code embed करना। Ancestor element पर xml:space="preserve" set करें और conformant processor descendants में हर space और newline byte-for-byte keep करेगा।

Common XML Errors जो Formatter Catch करता है

  1. Text content में Unescaped & Naked ampersand हमेशा invalid है; &amp; use करें।
  2. Mismatched या unclosed tags। सबसे common parse error। हर <tag> को matching </tag> चाहिए (या self-closing form <tag/> use करें)।
  3. Multiple root elements। XML document में exactly एक outermost element होना चाहिए। यदि top level पर दो siblings हैं, तो उन्हें parent में wrap करें।
  4. Encoding mismatch। <?xml version="1.0" encoding="UTF-8"?> declaration file के actual byte encoding से match करना चाहिए। UTF-8 declaration के साथ UTF-16 BOM इस bug का classic version है।
  5. Attribute values में reserved characters। <tag attr="a<b"> invalid है भले ही < quotes के अंदर harmless लगता है।
  6. XML declaration के सामने Stray BOM। कुछ text editors silently UTF-8 BOM insert करते हैं जो strict parsers को confuse करता है।
  7. xml:space="preserve" regions के अंदर Mixed line endings। Inconsistent CR / LF / CRLF different platforms पर round-tripping करते समय visible whitespace artefacts produce कर सकते हैं।

अधिक अक्सर पूछे जाने वाले प्रश्न

मेरा XML Format No Output क्यों Produce करता है?

Most often इसलिए कि input well-formed नहीं है। Output के ऊपर error box browser के DOMParser की पहली parse error show करता है, usually missing या mismatched tag, unescaped &, या missing root element। Error fix करें और re-run करें।

क्या मेरा XML Server पर Upload होता है?

नहीं। Formatting और minification दोनों browser के built-in DOMParser और small JavaScript serialiser के अंदर run होते हैं। आपका XML page नहीं छोड़ता, जो SOAP payloads, configuration files, और credentials, internal URLs, या sensitive customer data contain करने वाली किसी भी चीज़ के लिए important है।

क्या Tool XSD या DTD Schema के विरुद्ध Validate कर सकता है?

नहीं। Schema validation schema file load करने और उसके references resolve करने की ज़रूरत है, जो browser के well-formedness check से different problem है। XSD validation के लिए, command line पर Saxon या xmllint --schema use करें, या W3C XML Schema validator service।

क्या XML 2026 में अभी भी Relevant है, या मुझे बस JSON Use करना चाहिए?

यह इस बात पर depend करता है कि आप क्या कर रहे हैं। New REST APIs के लिए, JSON almost always सही pick है। लेकिन XML अभी भी office documents (.docx, .xlsx), enterprise messaging (SOAP, financial standards), Android resources, EPUB, RSS / Atom, SVG, और most regulated-industry interchanges के लिए default है। XML read, format, और validate करना जानना अभी भी baseline skill है; यह बस JSON की तरह हर दिन का first tool नहीं है।

«preserve all node types» का Formatter के लिए क्या मतलब है?

CDATA sections, comments, और processing instructions सभी input में exactly जैसे appear होते हैं वैसे kept रहते हैं, formatter केवल elements के बीच whitespace change करता है। इसलिए <![CDATA[ if (a < b) { … } ]]> block byte-for-byte round-trips होता है भले ही उसकी content में < characters हों जिन्हें otherwise escape करने की ज़रूरत होती।

संबंधित टूल

निःशुल्क JSON फॉर्मेटर और वैलिडेटर JSON से YAML मुफ़्त SQL फ़ॉर्मेटर