fast-xml-parser
Validate XML or Parse XML to JS/JSON very fast without C/C++ based libraries
Last updated 7 years ago by amitgupta .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install fast-xml-parser 
SYNC missed versions from official npm registry.

fast-xml-parser

Known Vulnerabilities NPM quality Coverage Status Try me NPM total downloads

Validate XML, Parse XML to JS Object, or Build XML from JS Object without C/C++ based libraries and no callback.

XML Parser v5 is added for experimental use https://solothought.com

Sponsor this project 👉 Stubmatic donate button

Current Sponsors

Check the complete list at ThankYouBackers for our sponsors and supporters.

Through Github

Through OpenCollective

Users

Check the bigger list

The list of users is collected either from the list published by Github, communicated directly through mails/chat , or from other resources. If you feel that your name in the above list is incorrectly published or you're not the user of this library anymore then you can inform us to remove it. We'll do the necessary changes ASAP.

If you want to be an anonymous user of this application and don't want to be highlighted anywhere then you can contact me at

Main Features

FXP logo
  • Validate XML data syntactically
  • Parse XML to JS Object
  • Build XML from JS Object
  • Works with node packages, in browser, and in CLI (press try me button above for demo)
  • Faster than any other pure JS implementation.
  • It can handle big files (tested up to 100mb).
  • Controlled parsing using various options
  • XML Entities, HTML entities, and DOCTYPE entites are supported.
  • unpaired tags (Eg <br> in HTML), stop nodes (Eg <script> in HTML) are supported.
  • You can restore almost same XML from JSON
  • Supports comments
  • It can preserve Order of tags in JS object
  • You can control if a single tag should be parsed into array.
  • Supports parsing of PI (Processing Instruction) tags with XML declaration tags
  • And many more other features.

v5

I developed v5 in Apr 2023. And I didn't get the chance to complete all the features. I've ensured that new features don't impact performance. With v5, you have more control on parsing output. Check docs for syntax help and basic understanding.

Please leave a comment in discussion forum for your suggestions and if you really need v5.

How to use

To use as package dependency $ npm install fast-xml-parser or $ yarn add fast-xml-parser

To use as system command $ npm install fast-xml-parser -g

To use it on a webpage include it from a CDN

Example

As CLI command

$ fxparser some.xml

In a node js project

const { XMLParser, XMLBuilder, XMLValidator} = require("fast-xml-parser");

const parser = new XMLParser();
let jObj = parser.parse(XMLdata);

const builder = new XMLBuilder();
const xmlContent = builder.build(jObj);

In a HTML page

<script src="path/to/fxp.min.js"></script>
:
<script>
  const parser = new fxparser.XMLParser();
  parser.parse(xmlContent);
</script>

Check lib folder for different browser bundles

Bundle Name Size
fxbuilder.min.js 5.2K
fxparser.js 50K
fxparser.min.js 17K
fxp.min.js 22K
fxvalidator.min.js 5.7K

Documents

v3

v4

  1. GettingStarted.md
  2. XML Parser
  3. XML Builder
  4. XML Validator
  5. Entities
  6. HTML Document Parsing
  7. PI Tag processing

Performance

XML Parser

  • Y-axis: requests per second
  • X-axis: File size

Large files

  • Y-axis: requests per second
  • X-axis: File size

XML Builder

  • Y-axis: requests per second

negative means error

Supporters

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! 🙏 [Become a backer]

License

  • MIT License

Donate $5

Current Tags

  • 4.5.0                                ...           latest (2 months ago)

136 Versions

  • 4.5.0                                ...           2 months ago
  • 4.4.1                                ...           4 months ago
  • 4.4.0                                ...           6 months ago
  • 4.3.6                                ...           8 months ago
  • 4.3.5                                ...           9 months ago
  • 4.3.4                                ...           10 months ago
  • 4.3.3                                ...           10 months ago
  • 4.3.2                                ...           a year ago
  • 4.3.1                                ...           a year ago
  • 4.3.0                                ...           a year ago
  • 4.2.7                                ...           a year ago
  • 4.2.6                                ...           a year ago
  • 4.2.5                                ...           a year ago
  • 4.2.4                                ...           a year ago
  • 4.2.3                                ...           a year ago
  • 4.2.2                                ...           2 years ago
  • 4.2.1                                ...           2 years ago
  • 4.2.0                                ...           2 years ago
  • 4.1.4                                ...           2 years ago
  • 4.1.3                                ...           2 years ago
  • 4.1.2                                ...           2 years ago
  • 4.1.1                                ...           2 years ago
  • 4.1.0                                ...           2 years ago
  • 4.0.15                                ...           2 years ago
  • 4.0.14                                ...           2 years ago
  • 4.0.13                                ...           2 years ago
  • 4.0.12                                ...           2 years ago
  • 4.0.11                                ...           2 years ago
  • 4.0.10                                ...           2 years ago
  • 4.0.9                                ...           2 years ago
  • 4.0.8                                ...           2 years ago
  • 4.0.7                                ...           3 years ago
  • 4.0.6                                ...           3 years ago
  • 4.0.5                                ...           3 years ago
  • 4.0.4                                ...           3 years ago
  • 4.0.3                                ...           3 years ago
  • 4.0.2                                ...           3 years ago
  • 4.0.1                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 4.0.0-beta.8                                ...           3 years ago
  • 4.0.0-beta.7                                ...           3 years ago
  • 4.0.0-beta.6                                ...           3 years ago
  • 4.0.0-beta.5                                ...           3 years ago
  • 4.0.0-beta.4                                ...           3 years ago
  • 4.0.0-beta.3                                ...           3 years ago
  • 4.0.0-beta.2                                ...           3 years ago
  • 4.0.0-beta.0                                ...           3 years ago
  • 3.21.1                                ...           3 years ago
  • 3.21.0                                ...           3 years ago
  • 3.20.3                                ...           3 years ago
  • 3.20.0                                ...           3 years ago
  • 3.19.0                                ...           4 years ago
  • 3.18.0                                ...           4 years ago
  • 3.17.6                                ...           4 years ago
  • 3.17.5                                ...           4 years ago
  • 3.17.4                                ...           4 years ago
  • 3.17.3                                ...           4 years ago
  • 3.17.2                                ...           4 years ago
  • 3.17.1                                ...           4 years ago
  • 3.17.0                                ...           4 years ago
  • 3.16.0                                ...           5 years ago
  • 3.15.1                                ...           5 years ago
  • 3.15.0                                ...           5 years ago
  • 3.14.0                                ...           5 years ago
  • 3.13.0                                ...           5 years ago
  • 3.12.21                                ...           5 years ago
  • 3.12.20                                ...           5 years ago
  • 3.12.19                                ...           5 years ago
  • 3.12.18                                ...           5 years ago
  • 3.12.17                                ...           5 years ago
  • 3.12.16                                ...           6 years ago
  • 3.12.14                                ...           6 years ago
  • 3.12.13                                ...           6 years ago
  • 3.12.12                                ...           6 years ago
  • 3.12.11                                ...           6 years ago
  • 3.12.10                                ...           6 years ago
  • 3.12.9                                ...           6 years ago
  • 3.12.8                                ...           6 years ago
  • 3.12.7                                ...           6 years ago
  • 3.12.5                                ...           6 years ago
  • 3.12.4                                ...           6 years ago
  • 3.12.3                                ...           6 years ago
  • 3.12.2                                ...           6 years ago
  • 3.12.0                                ...           6 years ago
  • 3.11.2                                ...           6 years ago
  • 3.11.1                                ...           6 years ago
  • 3.11.0                                ...           6 years ago
  • 3.10.0                                ...           7 years ago
  • 3.9.11                                ...           7 years ago
  • 3.9.10                                ...           7 years ago
  • 3.3.9                                ...           7 years ago
  • 3.3.8                                ...           7 years ago
  • 3.3.7                                ...           7 years ago
  • 3.3.6                                ...           7 years ago
  • 3.3.5                                ...           7 years ago
  • 3.3.4                                ...           7 years ago
  • 3.3.3                                ...           7 years ago
  • 3.3.2                                ...           7 years ago
  • 3.3.1                                ...           7 years ago
  • 3.3.0                                ...           7 years ago
  • 3.2.4                                ...           7 years ago
  • 3.2.3                                ...           7 years ago
  • 3.2.2                                ...           7 years ago
  • 3.2.1                                ...           7 years ago
  • 3.2.0                                ...           7 years ago
  • 3.0.1                                ...           7 years ago
  • 3.0.0                                ...           7 years ago
  • 2.9.4                                ...           7 years ago
  • 2.9.3                                ...           7 years ago
  • 2.9.2                                ...           7 years ago
  • 2.9.1                                ...           7 years ago
  • 2.9.0                                ...           7 years ago
  • 2.8.3                                ...           7 years ago
  • 2.8.2                                ...           7 years ago
  • 2.8.1                                ...           7 years ago
  • 2.8.0                                ...           7 years ago
  • 2.7.4                                ...           7 years ago
  • 2.7.3                                ...           7 years ago
  • 2.7.2                                ...           7 years ago
  • 2.7.1                                ...           7 years ago
  • 2.7.0                                ...           7 years ago
  • 2.6.0                                ...           7 years ago
  • 2.5.1                                ...           7 years ago
  • 2.5.0                                ...           7 years ago
  • 2.4.4                                ...           7 years ago
  • 2.4.3                                ...           7 years ago
  • 2.4.1                                ...           8 years ago
  • 2.3.1                                ...           8 years ago
  • 2.3.0                                ...           8 years ago
  • 2.2.1                                ...           8 years ago
  • 2.2.0                                ...           8 years ago
  • 2.1.0                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Total 139
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 24
Dependencies (2)
Dev Dependencies (10)

© 2010 - cnpmjs.org x YWFE | Home | YWFE