Code & Data
Convert XML to JSON
Paste XML and get JSON. Attributes become @-prefixed keys, repeated elements become arrays, and CDATA comes through as text.
Indentation
XML has no arrays. An element appearing once becomes a value and twice becomes a list, which means the shape of the output depends on the data — worth knowing if something downstream expects an array.
Paste XML above and the JSON appears here.
- Runs in your browser
- No account required
- Free to use
How it works
The array problem, and how it is resolved
XML has no arrays — a list is the same element name appearing several times. So whether a single `<item>` means one value or a one-element list is genuinely ambiguous, and no converter can know. The rule here is the common one: one occurrence becomes a value, two or more become an array. It is worth understanding, because it means the shape of the JSON depends on the data rather than on the schema.
Attributes are prefixed, not merged
An attribute becomes a key beginning `@`, so `<a id="1">` gives `{"@id": "1"}`. Merging attributes and child elements into the same namespace would silently collide when an element has both an `id` attribute and an `<id>` child.
A leaf is just its text
An element with no attributes and no element children becomes its text content rather than an object wrapping it. That is the shape people expect, and it keeps simple documents simple.
What it does
Attributes optional
One checkbox drops them entirely, for when you want the data and not the markup metadata.
Formatted or minified output
Two spaces, four, or no whitespace at all.
Parse errors with a line
Malformed XML is reported the same way the formatter reports it, rather than producing partial JSON.
Runs in your browser
No upload. What you paste in is never sent anywhere.
Practical advice
Getting a better result
- Check the output shape before relying on it: an element that appears once in your sample and twice in production will change from a value to an array.
- If you only need the data, turn attributes off — it usually halves the size of the result.
- Mixed content, where an element holds both text and child elements, has no clean JSON equivalent. The text is kept under a #text key, but that shape is awkward by nature.
Questions
Things people ask
Why did my single element not become an array?
Because XML gives no way to tell a one-item list from a single value — both are one element. The convention used here is that one occurrence is a value and two or more form an array. If your consumer always expects an array, it is worth normalising after conversion.
What happens to attributes?
Each becomes a key prefixed with @, so they cannot collide with a child element of the same name. There is a checkbox to drop them entirely.
Related tools
JSON Formatter
Format and minify JSON, with errors that name the line.
Runs entirely in your browser
Open toolJSON Validator
Check JSON and get the line, column and cause of any error.
Runs entirely in your browser
Open toolJSON Viewer
Explore JSON as a collapsible tree instead of scrolling it.
Runs entirely in your browser
Open toolJSON to CSV
Turn an array of objects into a spreadsheet-ready CSV.
Runs entirely in your browser
Open toolWho builds these
Free tools by day. Websites that earn their keep by trade.
KuConvert is built by KUDUY, a web design and development agency. From custom WordPress builds to SEO and e-commerce, everything they do is engineered to bring you more qualified traffic and turn it into revenue.
Web Design
Custom, conversion-focused web design that captivates visitors and turns them into paying customers. Mobile-first, fast, and built to rank.
Web Development
Custom WordPress websites built with clean code, blazing-fast performance (Core Web Vitals optimised), and enterprise-grade security.
E-Commerce
Online stores that convert visitors to customers with seamless shopping experiences.
SEO
Technical SEO, keyword research, on-page optimisation and local SEO strategies that drive qualified organic traffic.
Digital Marketing
Data-driven campaigns that deliver measurable ROI across every channel.
Branding
Memorable brand identities that stand out in any market and build lasting trust.
Website Help
One-on-one expert support for bug fixes, updates and ongoing maintenance — without a long-term retainer.
Fixed scope, no surprise invoices
Most sites ship in four to eight weeks with the scope and the price agreed up front.
SEO from day one
Search is designed into the build — structure, schema and Core Web Vitals — not retrofitted.
A team, not a ticket queue
A project manager, a designer and a developer you can actually reach.
Need your whole site to load this fast?
Images are usually the heaviest thing on a page and the easiest win. KUDUY works on site speed, image delivery and Core Web Vitals for teams who would rather not do it by hand.
This tool runs entirely in your browser. Your files are never uploaded.