NaturalIntelligence/fast-xml-parser

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.

JavaScript

3,139

1,056 commits

updated Oct 1, 2026

See the code

README

fast-xml-parser

NPM total downloads

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

FXP logo
  • Validate XML data syntactically. Use detailed-xml-validator to verify business rules.
  • Parse XML to JS Objects and vice versa
  • Common JS, ESM, and browser compatible
  • Faster than any other pure JS implementation.

It can handle big files (tested up to 100mb). XML Entities, HTML entities, and DOCTYPE entites are supported. Unpaired tags (Eg <br> in HTML), stop nodes (Eg <script> in HTML) are supported. It can also preserve Order of tags in JS object

IMPORTANT: It is recommended to use fast-xml-validator instead of inbuilt validator.

Before using this library

  • Flexible-XML-Parser is 1.25 times faster than this library when not preserving order of tags. Takes less memory when processing big files. Supports incomplete XML/HTML. And output is highly customizable. Build whatever you want. So if you're fine with some extra configuration then try it out.
  • @nodable/sax is a SAX parser based on Flexible-XML-Parser. 3-4 times faster than sax and support all features of base package like incomplete input, streams, skipping certain tags from processing etc.
  • fast-xml-validator is separated from this package. Has many features. Faster. You can exvlude particular tag from validation. And much more.
  • fast-xml-builder is a XML to JS Object builder used in this package in past. Now, it supports more features, and faster. So, recommend to use it directly.

Your Support, Our Motivation

Please join Discord community for pre release announcements and discussions.

Financial Support

Sponsor this project




This is a donation. No goods or services are expected in return. Any requests for refunds for those purposes will be rejected.

Users

more

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


More about this library

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 NameSize
fxbuilder.min.js6.5K
fxparser.min.js20K
fxp.min.js26K
fxvalidator.min.js5.7K

Documents

note:

  • Version 6 is released with version 4 for experimental use. Based on its demand, it'll be developed and the features can be different in final release.
  • Version 5 has the same functionalities as version 4.

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 from Open collective

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

License

  • MIT License

Donate $5

cli
command-line
fast
fast-xml-parser
js
js2xml
json
json2xml
locale
parser
rapid
validate
validator
xml
xml2js
xml2json
xml2nimn

NaturalIntelligence/fast-xml-parser

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.

JavaScript

3,139

1,056 commits

updated Oct 1, 2026

See the code

README

fast-xml-parser

NPM total downloads

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

FXP logo
  • Validate XML data syntactically. Use detailed-xml-validator to verify business rules.
  • Parse XML to JS Objects and vice versa
  • Common JS, ESM, and browser compatible
  • Faster than any other pure JS implementation.

It can handle big files (tested up to 100mb). XML Entities, HTML entities, and DOCTYPE entites are supported. Unpaired tags (Eg <br> in HTML), stop nodes (Eg <script> in HTML) are supported. It can also preserve Order of tags in JS object

IMPORTANT: It is recommended to use fast-xml-validator instead of inbuilt validator.

Before using this library

  • Flexible-XML-Parser is 1.25 times faster than this library when not preserving order of tags. Takes less memory when processing big files. Supports incomplete XML/HTML. And output is highly customizable. Build whatever you want. So if you're fine with some extra configuration then try it out.
  • @nodable/sax is a SAX parser based on Flexible-XML-Parser. 3-4 times faster than sax and support all features of base package like incomplete input, streams, skipping certain tags from processing etc.
  • fast-xml-validator is separated from this package. Has many features. Faster. You can exvlude particular tag from validation. And much more.
  • fast-xml-builder is a XML to JS Object builder used in this package in past. Now, it supports more features, and faster. So, recommend to use it directly.

Your Support, Our Motivation

Please join Discord community for pre release announcements and discussions.

Financial Support

Sponsor this project




This is a donation. No goods or services are expected in return. Any requests for refunds for those purposes will be rejected.

Users

more

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


More about this library

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 NameSize
fxbuilder.min.js6.5K
fxparser.min.js20K
fxp.min.js26K
fxvalidator.min.js5.7K

Documents

note:

  • Version 6 is released with version 4 for experimental use. Based on its demand, it'll be developed and the features can be different in final release.
  • Version 5 has the same functionalities as version 4.

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 from Open collective

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

License

  • MIT License

Donate $5

cli
command-line
fast
fast-xml-parser
js
js2xml
json
json2xml
locale
parser
rapid
validate
validator
xml
xml2js
xml2json
xml2nimn

Significant stargazers

XhmikosR

3,472 followers · starred May 2026

David Pine

1,019 followers · starred Sep 2025

John Reilly

478 followers · starred Nov 2022

Travis Van Nimwegen

404 followers · starred Jan 2025