Package Exports
- react-native-turboxml
- react-native-turboxml/package.json
Readme
TurboXML – Fast Native XML Parser for React Native
A high-performance native XML parser for React Native using TurboModules and the New Architecture.
4× faster than JavaScript-based parsers like react-native-xml2js.
Features
- Native performance – Parses XML natively on both platforms (Kotlin on Android, Objective-C on iOS)
- TurboModules + JSI – Built for React Native's New Architecture
- Async & non-blocking – Parsing runs on background threads
- Fully typed – TypeScript definitions included
- Simple API – Single function, returns a Promise
Installation
npm install react-native-turboxml
# or
yarn add react-native-turboxmliOS
cd ios && pod installRequirements
- React Native 0.71+
- New Architecture enabled
- Android 5.0+ / iOS 13.0+
Usage
import { parseXml } from 'react-native-turboxml';
const xml = `
<book id="123">
<title>The Great Gatsby</title>
<author>F. Scott Fitzgerald</author>
<year>1925</year>
</book>
`;
const result = await parseXml(xml);
console.log(result);Output
{
"book": {
"_attributes": { "id": "123" },
"_children": [
{ "title": { "_text": "The Great Gatsby" } },
{ "author": { "_text": "F. Scott Fitzgerald" } },
{ "year": { "_text": "1925" } }
]
}
}API
function parseXml(xml: string): Promise<Record<string, unknown>>;| Parameter | Type | Description |
|---|---|---|
xml |
string |
The XML string to parse |
Returns: A Promise that resolves to a JavaScript object representing the parsed XML.
Output Structure
| Key | Description |
|---|---|
_attributes |
Object containing element attributes |
_text |
Text content of the element |
_children |
Array of child elements |
Why TurboXML?
JavaScript-based XML parsers run on the JS thread and can block your UI during large file parsing. TurboXML uses native code on both platforms:
- Android: Jackson XmlMapper with Kotlin coroutines
- iOS: NSXMLParser with GCD
This means parsing happens on background threads and communicates directly via JSI – no bridge serialization overhead.
Use cases
- Offline maps and geospatial data (KML, GPX)
- Configuration files
- API responses in XML format
- Data import/export
Comparison
| Parser | Native | New Architecture | Async |
|---|---|---|---|
| react-native-turboxml | Yes | Yes (TurboModules) | Yes |
| react-native-xml2js | No | No | Yes |
| fast-xml-parser | No | No | No |
Contributing
Contributions are welcome! Feel free to open issues or submit PRs.
License
MIT