XML to JSON converter that handles attributes, arrays and namespaces
Product feeds, invoices and old SOAP APIs still speak XML, while your code wants JSON. The hard parts are attributes, elements that appear once in one record and five times in the next, and namespace prefixes. Your todo.is agent converts the file with clear rules for each and tells you what it decided.
The prompt
- Convert the attached XML to JSON: [ATTACH THE XML]. The repeating record is [RECORD ELEMENT]. Put attributes [ATTRIBUTE STYLE]. Always make these elements arrays, even with one item: [ALWAYS ARRAYS]. Strip namespace prefixes unless two would clash. Turn numeric and true/false text into numbers and booleans, and keep empty elements as null. Pretty-print with 2 spaces, validate the JSON and send the .json file with a short note listing the rules you used.
What to change
- [ATTACH THE XML]: Attach an .xml file (product feed, sitemap, invoice, RSS, export), or paste a public URL.
- [RECORD ELEMENT]: E.g. "<item>", "<product>", "<url>" or "detect it".
- [ATTRIBUTE STYLE]: E.g. "as normal keys", "as keys starting with @" or "in an attributes object".
- [ALWAYS ARRAYS]: E.g. "image, category" or "none".
Example result
- XML to JSON: product_feed.xml
- Root <rss> → channel → 1,980 <item> elements · output: an array of 1,980 product objects
- Input (one item)
- <item>
- <g:id>SKU-2201</g:id>
- <title>Linen Shirt</title>
- <g:price currency="EUR">39.00</g:price>
- <g:availability>in_stock</g:availability>
- <g:image_link>https://example.com/img/2201-a.jpg</g:image_link>
- </item>
- Output (same item)
- {
- "id": "SKU-2201",
- "title": "Linen Shirt",
- "price": { "currency": "EUR", "value": 39.0 },
- "availability": "in_stock",
- "image_link": ["https://example.com/img/2201-a.jpg"]
- }
- Rules used
- • Namespaces: the g: prefix was removed. No two keys clashed
- • Attributes: kept as normal keys. When an element had both an attribute and text, the text went into "value"
- • Arrays: image_link and product_type are always arrays, even with one entry, so your code does not need two cases
- • Types: 39.00 became 39.0; "true"/"false" became booleans; IDs stayed strings
- • CDATA: descriptions in CDATA were kept as plain text, HTML tags included
- • Entities: & and " decoded to & and "
- Checks
- • XML was well-formed
- • 1,980 items in, 1,980 objects out
- • 23 items had no price element. They have "price": null
- Ask for a JSON Schema or a CSV copy of the same data if you need it.
How to do it with todo.is
- Copy the prompt, name the repeating element and pick how attributes should look.
- Attach the XML in todo.is, or give your agent a public feed URL in the chat.
- Your agent parses the file, applies your rules and validates the output.
- Download the .json. Make it a daily recurring to-do if the feed changes and you want fresh JSON each morning.
Tips for a better result
- Name elements that can repeat. Without that, a single image becomes a string in one record and an array in the next.
- If your code already reads a JSON format, paste one example object and your agent will match it.
- Large feeds can be split into JSON Lines, one record per line, which is easier to process in batches.
- For a sitemap, ask for just the loc and lastmod fields. The rest is usually noise.
XML to JSON converter: FAQ
- How are XML attributes converted to JSON? There is no single standard. Common choices are plain keys, keys starting with @, or a separate attributes object. Pick one in the prompt and your agent applies it to the whole file.
- Why do some elements become arrays and others not? An element that appears once looks like a single value, and one that repeats looks like a list. Listing elements that should always be arrays keeps the JSON consistent.
- Can it convert an RSS feed or sitemap? Yes. Both are XML. Attach the file or give the public URL.
- What if the XML is broken? Your agent reports the line where parsing fails and can try to repair simple problems, such as an unescaped ampersand, if you ask.
JavaScript is required to use the todo.is app.