Skip to content
camaro is an utility to transform XML to JSON, using Node.js binding to native XML parser pugixml, one of the fastest XML parser around.
JavaScript C++ Shell
Branch: develop
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update issue templates Jun 15, 2019
benchmark docs: update benchmark number on dev machine [skip ci] Aug 10, 2019
examples chore: add example of raw() Sep 16, 2019
test feat: add xpath raw() function Sep 16, 2019
.gitignore add js/wasm dist to git May 23, 2019
.npmignore fix: add .vscode and azure pipeline config to npmignore Jul 2, 2019
.npmrc fix: no package-lock in library May 12, 2018
.travis.yml ci: add windows Jun 10, 2019 add api doc May 31, 2019
LICENSE docs: update benchmark number on dev machine [skip ci] Aug 10, 2019
appveyor.yml no need to install node-pre-gyp anymore May 24, 2019
azure-pipelines.yml ci: add all node from 8 to 12 Jun 20, 2019
azure-test.yml azure pipeline typo file name Jun 17, 2019 fix: disable pugi exceptions Sep 10, 2019
index.d.ts fix: update typescript definitions for recent API changes Oct 8, 2019
index.js wip May 31, 2019
intro.png First commit Jun 1, 2017
package.json release: pump version to 4.1.2 Oct 9, 2019


camaro is an utility to transform XML to JSON, using Node.js binding to native XML parser pugixml, one of the fastest XML parser around.

npm npm bundle size Build Status Travis AppVeyor TypeScript definitions on DefinitelyTyped npm

Demo on

🤘 Features

  • Transform XML to JSON. Only take properties that you're interested in.
  • Output is a ready to use JS object.
  • Written in C++ and compiled down to WebAssembly so no compilation needed.
  • Work on all major platforms (OS X, Linux and Windows and the web). See Travis CI and AppVeyor build status for details.
  • No need to build binary whenever a new Node version released.
  • AWS Lambda friendly (or serverless in general).
  • SUPER FAST!! We're using pugixml underneath. It's one of the fastest xml parser around.
  • Small footprint (Zero dependencies).
  • Pretty print XML.

🚧 Upgrading notes from version 3 🚧

  • camaro v4 slows down quite a bit since switching to WebAssembly. It's still the fastest but slower by big margin. WebAssembly and Emscripten are rather new to me so bare with me while I'm figuring out the performance issue. If you need pure speed, just use camaro v3.
  • 🚨BREAKING: transform() is now an async function.
  • 🚨BREAKING: change the way transform is imported const { transform } = require('camaro')
  • plan to add toJson() function to convert the whole XML input.
  • DONE: plan to add prettyPrint() to pretty print XML.

🔥 Benchmark

camaro x 362 ops/sec ±0.31% (87 runs sampled)
rapidx2j x 226 ops/sec ±0.27% (88 runs sampled)
xml2json x 46.32 ops/sec ±1.39% (61 runs sampled)
xml2js x 50.51 ops/sec ±7.22% (68 runs sampled)
fast-xml-parser x 256 ops/sec ±0.63% (86 runs sampled)
xml-js x 45.05 ops/sec ±6.19% (61 runs sampled)
  • Please note that this is an unfair game for camaro because it only transform those fields specified in template. The whole reason of me creating this is because most of the time, I'm just interested in some of the data in the whole XML mess.

  • Benchmark run on MacBookPro14,1 - Intel Core i5 CPU @ 2.30GHz using Node v8.10.0.

  • I may expose another method to transform the whole XML tree so that the benchmark will better reflect the real performance.

For complete benchmark, see benchmark/



yarn add camaro
# npm install camaro


You can use our custom template format powered by XPath.

We also introduce some custom syntax such as:

  • if a path start with #, that means it's a constant. E.g: #1234 will return 1234
  • if a path is empty, return blank
  • Some string manipulation functions which are not availble in XPath 1.0 such as lower-case, upper-case, title-case, camel-case, snake-case and string-join. Eventually, I'm hoping to add all XPath 2.0 functions but these are all that I need for now. PRs welcome.

The rest are pretty much vanilla XPath 1.0.

For complete API documentation, please see

const { transform, prettyPrint } = require('camaro')
const fs = require('fs')

const xml = fs.readFileSync('examples/ean.xml', 'utf-8')
const template = {
    cache_key: '/HotelListResponse/cacheKey',
    hotels: ['//HotelSummary', {
        hotel_id: 'hotelId',
        name: 'name',
        rooms: ['RoomRateDetailsList/RoomRateDetails', {
            rates: ['RateInfos/RateInfo', {
                currency: 'ChargeableRateInfo/@currencyCode',
                non_refundable: 'boolean(nonRefundable = "true")',
                price: 'number(ChargeableRateInfo/@total)'
            room_name: 'roomDescription',
            room_type_id: 'roomTypeCode'
    session_id: '/HotelListResponse/customerSessionId'

;(async function () {
    const result = await transform(xml, template)

    const prettyStr = await prettyPrint(xml, { indentSize: 4})


The MIT License

You can’t perform that action at this time.