fast-xml-parser
Validate XML, Parse XML, Build XML without C/C++ based libraries
Last updated 2 months 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

[![NPM quality][quality-image]][quality-url] 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.


ads-thePowerGlassesBook I had recently published a book, The Power Glasses. Please have a look. Your feedback would be helpful. You can mail me for a free copy.

Sponsor this project

Stubmatic donate button


fxp_sponsors

Users

more

The list of users are mostly published by Github or communicated directly. Feel free to contact if you find any information wrong.


Main Features

FXP logo
  • Validate XML data syntactically
  • Parse XML to JS Object
  • Build XML from JS Object
  • Compatible to node js packages, in browser, and in CLI (click 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>

Bundle size

Bundle Name Size
fxbuilder.min.js 6.5K
fxparser.min.js 20K
fxp.min.js 26K
fxvalidator.min.js 5.7K

Documents

v3v4v5
documents
  1. Getting Started
  2. XML Parser
  3. XML Builder
  4. XML Validator
  5. Entities
  6. HTML Document Parsing
  7. PI Tag processing
  1. Getting Started
  2. Features
  3. Options
  4. Output Builders
  5. Value Parsers

note: version 5 is released with version 4 tfor experimental use. Based on it's demand, it'll be developed and the features can be different in final release.

Performance

negative means error

XML Parser

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

XML Builder

* Y-axis: requests per second

Usage Trend

Usage Trend of fast-xml-parser

NPM Usage Trend of fast-xml-parser

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 (1)
Dev Dependencies (15)

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