diff --git a/__tests__/xml-to-json.test.ts b/__tests__/xml-to-json.test.ts
new file mode 100644
index 0000000..7097499
--- /dev/null
+++ b/__tests__/xml-to-json.test.ts
@@ -0,0 +1,144 @@
+/**
+ * @jest-environment jsdom
+ */
+import { xmlToJson } from "../lib/xmlToJson";
+
+describe("XML to JSON Converter", () => {
+ describe("Basic conversion", () => {
+ it("should convert simple XML to JSON", () => {
+ const xml = "
+ This free tool quickly converts Markdown to HTML. Ideal for blog
+ posts, documentation, README files, or web content. Just paste your
+ Markdown and get clean HTML code. Built with 💜 by the Jam developers.
+
+ To convert Markdown to HTML, simply paste your Markdown content in the
+ input field and the HTML output will appear instantly. No signup
+ required.
+
+ Our converter supports all standard Markdown syntax including headers,
+ bold, italic, links, images, code blocks, lists, and more.
+
+ Need to work with other formats? Check out our{" "}
+ JSON Formatter or{" "}
+ XML to JSON converter.
+
+ Markdown is a lightweight markup language that's easy to write and
+ read. HTML (HyperText Markup Language) is the standard language for
+ creating web pages.
+
+ Our free, open-source, and ad-free XML to JSON converter makes it
+ easy to transform your data formats. Convert configuration files,
+ API responses, or legacy XML data into modern JSON with just a few
+ clicks. Built with 💜 for developers by developers.
+
+ Looking for YAML conversion instead? Check out{" "}
+
+ jsontoyamlconverter.com
+ {" "}
+ for JSON ↔ YAML conversions.
+
+ XML (eXtensible Markup Language) has been a standard for data
+ exchange for decades, but JSON (JavaScript Object Notation) has
+ become the preferred format for modern web development. Converting{" "}
+ XML to JSON is essential when you need:
+ Converting XML data to JSON has never been easier:
+ Both XML and JSON have their strengths. Here's when to use each:
+ Check out our other data conversion utilities:How to Use the Markdown to HTML Converter
+ Supported Markdown Syntax
+
+
+
Use # for h1, ## for h2, up to ###### for h6.
+
Use **text** or __text__ for bold,
+ *text* or _text_ for italic.
+
Use [link text](url) to create hyperlinks.
+
Use  to embed images.
+
Use `inline code` or triple backticks for code
+ blocks with syntax highlighting.
+
Use - or * for unordered lists, numbers for
+ ordered lists.
+
Use > at the start of a line for
+ quotes.
+ Benefits of Converting Markdown to HTML
+
+
+
Convert your Markdown documentation or
+ blog posts directly to HTML for web publishing.
+
Transform Markdown into HTML for rich
+ email content that displays correctly in all email clients.
+
Convert README files and documentation
+ written in Markdown to HTML for hosting on websites.
+
Many CMS platforms accept HTML
+ input, making this converter useful for content migration.
+ Markdown vs HTML: When to Use Each
+
+
+
Markdown is faster to write and more
+ readable in its raw form. HTML offers more control over formatting
+ and layout.
+
Markdown files are plain text and work
+ anywhere. HTML requires a browser or renderer to display properly.
+
HTML supports advanced features like forms,
+ tables with styling, and interactive elements. Markdown is simpler
+ but covers most common formatting needs.
+
Markdown is perfect for documentation,
+ README files, and notes. HTML is essential for web pages and
+ applications.
+ FAQs
+
+
+
Yes, our tool
+ instantly converts Markdown syntax to valid HTML code that you can
+ use on any website.
+
Yes, this Markdown to
+ HTML converter is completely free, open source, and has no ads.
+
{" "}
+ Yes, fenced code blocks with language specification are converted to
+ HTML with appropriate class names for syntax highlighting.
+
Absolutely. All conversion happens
+ in your browser. Your data never leaves your device.
+
Our converter
+ supports standard Markdown syntax including GitHub Flavored Markdown
+ features like task lists and strikethrough.
+
Yes, the converter
+ handles documents of any size efficiently since all processing is
+ done client-side.
+ Why Convert XML to JSON?
+
+
+
Most modern REST APIs use
+ JSON, making conversion essential for integrating legacy XML data.
+
JSON is more compact than XML,
+ reducing bandwidth and improving performance.
+
JSON is native to
+ JavaScript, making it easier to work with in web applications.
+
JSON's simpler syntax makes data
+ easier to read and understand compared to verbose XML.
+ How to Use Our XML to JSON Converter
+
+
+
Paste your XML code into the input box.
+
Instantly receive your JSON output. No
+ registration or ads.
+
Copy your JSON data and integrate it into
+ your project.
+ Key Features of Our XML to JSON Tool
+
+
+
Your data never leaves your
+ browser - complete privacy guaranteed.
+
XML attributes are preserved as
+ @attributes in the JSON output.
+
Multiple elements with the same name
+ are automatically converted to arrays.
+
CDATA sections are properly extracted
+ as text content.
+
Invalid XML is detected and reported
+ immediately.
+ XML vs JSON: When to Use Each
+
+
+
+ Better for documents with mixed content, complex schemas, XSLT
+ transformations, and SOAP web services.
+
Preferred for REST APIs, configuration files,
+ web applications, and when file size matters.
+ FAQs
+
+
+
XML (eXtensible Markup Language) is a
+ markup language that defines rules for encoding documents in a
+ format that is both human-readable and machine-readable.
+
JSON (JavaScript Object Notation) is a
+ lightweight data format used to transmit data between servers and
+ web applications.
+
XML attributes are
+ converted to an @attributes object in the JSON output, preserving
+ all attribute data.
+
While more complex
+ due to attribute handling, you can manually restructure JSON back
+ to XML format.
+
Yes! All processing happens in
+ your browser. Your XML data is never sent to any server.
+
For JSON to YAML conversion,
+ visit{" "}
+
+ jsontoyamlconverter.com
+
+ .
+ Related Tools
+
+
+
`;
+ }
+ );
+
+ // Inline code (single backticks)
+ html = html.replace(/`([^`]+)`/g, "${code.trim()}$1");
+
+ // Headers (h1-h6)
+ html = html.replace(/^###### (.+)$/gm, "$1
");
+ html = html.replace(/^##### (.+)$/gm, "$1
");
+ html = html.replace(/^#### (.+)$/gm, "$1
");
+ html = html.replace(/^### (.+)$/gm, "$1
");
+ html = html.replace(/^## (.+)$/gm, "$1
");
+ html = html.replace(/^# (.+)$/gm, "$1
");
+
+ // Horizontal rule
+ html = html.replace(/^(-{3,}|\*{3,}|_{3,})$/gm, "
");
+
+ // Bold and italic combinations
+ html = html.replace(/\*\*\*(.+?)\*\*\*/g, "$1");
+ html = html.replace(/___(.+?)___/g, "$1");
+
+ // Bold
+ html = html.replace(/\*\*(.+?)\*\*/g, "$1");
+ html = html.replace(/__(.+?)__/g, "$1");
+
+ // Italic
+ html = html.replace(/\*(.+?)\*/g, "$1");
+ html = html.replace(/_(.+?)_/g, "$1");
+
+ // Strikethrough
+ html = html.replace(/~~(.+?)~~/g, "$1");
+
+ // Blockquotes
+ html = html.replace(/^> (.+)$/gm, "$1
");
+ // Merge consecutive blockquotes
+ html = html.replace(/<\/blockquote>\n/g, "\n");
+
+ // Unordered lists
+ html = html.replace(/^[*\-+] (.+)$/gm, "
\n${match}
\n`);
+
+ // Ordered lists
+ html = html.replace(/^\d+\. (.+)$/gm, "');
+
+ // Task lists
+ html = html.replace(
+ /
([\s\S]*?)<\/p>/g, (_match, content) => { + return `
${content.replace(/\n/g, "
")}