Per platform
| iPhone and iPad | High fidelity | |
|---|---|---|
| Android | High fidelity |
How it works
- Import the XML file, or share it with Tramuta.
- Pick JSON among the formats.
- Tap “Convert”, then “Share” or “Save to…”.
Many services, business-software exports and feeds speak XML, while scripts and modern apps prefer JSON. Tramuta converts XML to JSON right on the phone or tablet: the file stays on the device, even when it holds customer or invoice data.
How XML maps onto JSON
XML and JSON don’t share the same shape, so rules are needed. Tramuta’s are fixed and predictable:
- the root element’s name is dropped and its content kept (its attributes become keys);
- an element with children or attributes becomes an object;
- attributes become keys with their own name (with
@in front only when a child has the same name); - children with the same name become a list, in file order;
- an element with only text becomes the string of its text, trimmed, with no type conversion (CDATA text included).
With a small XML like this:
<radice>
<riga id="7"><nome>tè</nome><nota>4.50</nota><nota>seconda</nota></riga>
<riga id="8"><nome>caffe</nome></riga>
</radice>
the JSON is {"riga": [{"id": "7", "nome": "tè", "nota": ["4.50", "seconda"]}, {"id": "8", "nome": "caffe"}]}, written across several lines with two-space indentation.
What doesn’t make it into the JSON
The conversion is “High fidelity” for XML made of elements and attributes, which covers most data exports. Some things, though, have no place in JSON and Tramuta doesn’t carry them over: comments and processing instructions; namespace prefixes (the local name stays, so <g:price> becomes price, while declarations such as xmlns:g show up as ordinary keys); and the text of an element that also has attributes or children, for example the 4.50 in <price currency="EUR">4.50</price>, where only currency remains. If your XML is written that way, check the result.
XML to JSON on iPhone, iPad and Android
Reading the XML and writing the JSON is the app’s own Dart code, the same on both platforms. Invalid XML stops the conversion with the line and column of the error. There is nothing to set: between two tree formats the “Options” sheet stays empty, because separator, header row and number recognition only concern CSV and TSV tables.
How to do it in Tramuta
- Tap “Choose or drop files” and pick the
.xmlfile, or send it to Tramuta with “Share”. - Under “Convert to”, pick “JSON”.
- Tap “Convert”, then “Save to…”, “Share” or “Open in…”.
You can then make the JSON easier to read with JSON to YAML or turn it into a table with JSON to CSV. If you start from a CSV list, the page you want is CSV to JSON.
Questions
What happens to the root element?
Its name is dropped: the JSON holds what is inside the root. From “<catalog><product>…</product></catalog>” you get an object with the key “product”, not “catalog”. Any attributes of the root become keys of that object.
Does an element that appears only once become a list?
No. It becomes a list only when the same name repeats under the same parent; if it appears once it stays a single value. Keep that in mind if the program reading the JSON always expects a list.
Can I tell attributes apart from elements?
An attribute becomes a key with its own name. It gets an “@” prefix only when a child element has the same name, so neither overwrites the other.
Do numbers in the XML become JSON numbers?
No. In XML everything is text, and Tramuta doesn’t guess types. “4.50” stays the string “4.50”, zeros included, and a code such as “007” keeps its leading zero.
Free on iPhone, iPad and Android
No ads, no in-app purchases, no account.
-
App Store
iPhone and iPad, iOS 15.0 or later.
Coming to the App Store -
Google Play
Android 7.0 or later.
Coming to Google Play -
APK for Android
Android 7.0 or later, without Google Play.
The APK is not available yet.