fast-xml-parser: parsing, validating and building XML in pure JavaScript
Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.
At a glance
- What is it?
- fast-xml-parser converts XML to JavaScript objects and back without C/C++ bindings. It is a good fit for Node services and browsers, and its own README points elsewhere for large files and for validation.
- Who is it for?
- Adopt fast-xml-parser if you need XML to JS object conversion or the reverse inside a Node service, a browser bundle or a CLI pipeline, and your inputs are well formed and moderate in size. Do not adopt it as your only validation layer, and do not pick it for very large or truncated documents: the README itself directs those cases to fast-xml-validator, fast-xml-builder and Flexible-XML-Parser.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 8 days ago.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 21, 2026, and from our analysis. They are not legal advice.
Star history
- NaturalIntelligence/fast-xml-parser3,143 ★ · +3
| Repository | 2026-09-24 | 2026-11-21 |
|---|---|---|
| NaturalIntelligence/fast-xml-parser | 3.1k | 3.1k |
3 Stars in the last 58 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What fast-xml-parser converts, and who ends up using it
XML still moves through build pipelines, SOAP endpoints, RSS feeds and configuration files, and JavaScript has no built-in parser that produces a plain object. fast-xml-parser fills that gap: it validates XML syntactically, parses XML into a JS object, and builds XML back from a JS object. The repository describes it as usable from CommonJS, ESM and the browser, with no C/C++ based libraries and no callback API.
The audience is narrower than 'anyone handling XML'. If you are writing a Node service that reads a supplier feed, a browser tool that inspects an uploaded document, or a build step that rewrites XML, the object-in, object-out model matches how you already work. If you need streaming with constant memory, or you want to react to events as tags open and close, a SAX-style parser is the better shape and this library is not it. The README also lists a users file, and the projects named there span build tooling, cloud SDKs and web frameworks, which tells you the typical consumer is a library or service that needs a dependency with no native build step.
The parse, build and validate trio inside the package
The package exports XMLParser and XMLBuilder classes, plus an XMLValidator object with a validate method. Parsing is an instance method, so you configure once and call parse per document. Building is the inverse, taking the same kind of object the parser produces. Validation is syntactic, and the README is explicit that business-rule checking belongs in a separate project, detailed-xml-validator.
The parser handles more than well-formed, plain XML. According to the README it supports XML entities, HTML entities and DOCTYPE entities, unpaired tags such as `<br>`, and stop nodes such as `<script>`. It can also preserve the order of tags in the resulting JS object, which matters when you serialize back and want the original sequence rather than an object's key order. The repository ships a browser bundle split by concern, with fxvalidator.min.js at 5.7K, fxbuilder.min.js at 6.5K, fxparser.min.js at 20K and the combined fxp.min.js at 26K, so a page that only parses does not have to carry the builder.
That entity and DOCTYPE support is also where the security question lives. XML entity expansion is a classic denial-of-service vector, and the README does not describe an entity-expansion limit or an option to disable DOCTYPE processing. Treat that as an open item to check in the source and in your dependency scanning, not as a documented guarantee.
Installing fast-xml-parser and parsing a first document
Install it as a project dependency with npm or yarn. The package is published as fast-xml-parser and the current release listed in the repository is 5.11.1.
npm install fast-xml-parserFor a global command-line install, the README gives the -g flag. That puts the fxparser binary on your path; the package.json maps the fxparser bin entry to src/cli/cli.js.
npm install fast-xml-parser -gWith the binary available, passing a file path prints the parsed result. The README shows exactly this invocation.
fxparser some.xmlIn a Node project, import the parser and builder classes and validator object, create a parser and call parse on your XML string. The same example appears in the README.
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);On a web page the README loads a bundle from a script tag and then constructs fxparser.XMLParser, calling parse on the XML content. Note the lowercase global: the library is exposed as fxparser in the browser, while the Node import is fast-xml-parser. The README does not document a TypeScript-specific setup beyond the types entry in package.json, which points to ./src/fxp.d.ts for imports and ./lib/fxp.d.cts for require.
Where the inbuilt validator stops and the wrong-tool cases begin
The clearest limitation is stated by the project itself. The README recommends using fast-xml-validator instead of the inbuilt validator, and points to detailed-xml-validator when you need to verify business rules. A syntactic check confirms tags are balanced and entities resolve; it says nothing about whether an order id is present or a date is in range. Teams that treat XMLValidator as a schema validator will ship a gap.
Size is the second boundary. The README says the library can handle big files and was tested up to 100mb, but it also recommends Flexible-XML-Parser for large-file work, noting that it takes less memory when processing big files and supports incomplete XML and HTML. That recommendation is the honest signal: if your input arrives as a stream, may be truncated, or is large enough that holding the whole document in memory is a problem, this library is the wrong tool. The same applies to event-driven processing. The project's own description says no callback, so there is no hook to fire on each element as it is read.
The README also notes that fast-xml-builder is now a standalone package and is faster, and that it was used inside this package in the past. So the builder you get here is not the project's current best answer to building XML, even though it remains exported.
fast-xml-parser compared with xml2js and SAX parsers
xml2js is the comparison most people reach for, since it also turns XML into JavaScript objects. The difference in approach is the API shape and the dependency footprint. xml2js is callback-based, and its parsing model grew around that style. fast-xml-parser is deliberately callback-free: you construct a parser, call parse, and get the object back synchronously. That makes it easier to use inside code that is already promise-based or synchronous, and it removes a layer of nesting when you parse several documents in a loop.
The other real alternative is a SAX-style parser, and the README names one directly. @nodable/sax is described as a SAX parser built on Flexible-XML-Parser, three to four times faster than sax, and supporting incomplete input, streams, and skipping certain tags from processing. That is a different architecture, not a different tuning: SAX emits events as it walks the document, so memory stays flat and you can abandon a document early. fast-xml-parser materializes the whole object. If you need to inspect one field out of a 200mb feed, the event model wins; if you need the object, the object model wins.
The README's own benchmark-adjacent claim is that Flexible-XML-Parser is 1.25 times faster than this library when order of tags is not preserved. The repository has a benchmark directory and a perf script, so you can reproduce measurements on your own documents rather than trusting a ratio.
Maintenance, versions and what the MIT licence lets you do
The repository is not archived, and the last push was on 2026-09-14. The release history shows v5.11.1 on 2026-08-27, v5.11.0 on 2026-08-16 and v5.10.1 on 2026-07-16, so the cadence over that window is roughly monthly. The package.json preversion script runs npm test, which means a release is gated on the Jasmine spec suite before publishing. For a dependency you ship to production, that is a reasonable signal about how versions are cut.
Upgrade cost is the practical question. The package is dual-published: the exports map sends import to ./src/fxp.js with types at ./src/fxp.d.ts, and require to ./lib/fxp.cjs with types at ./lib/fxp.d.cts. A project on CommonJS therefore resolves a different file from one on ESM, and the two type declaration files are separate. When you bump the major version, check both paths if your codebase mixes module systems. The files field publishes lib, src and CHANGELOG.md, so the changelog ships with the package and is the first place to look before an upgrade.
The licence is MIT. In practical terms that permits commercial use, modification and redistribution provided the copyright notice and permission notice are retained. That is a general description of the licence text, not legal advice; your own counsel should confirm how it applies to your distribution.
Editorial conclusion
Adopt fast-xml-parser if you need XML to JS object conversion or the reverse inside a Node service, a browser bundle or a CLI pipeline, and your inputs are well formed and moderate in size. Do not adopt it as your only validation layer, and do not pick it for very large or truncated documents: the README itself directs those cases to fast-xml-validator, fast-xml-builder and Flexible-XML-Parser. Before committing, verify three things against your own data: how your attributes and repeated tags appear in the parsed object, whether the inbuilt validator rejects the malformed input you actually receive, and whether the bundle you ship is fxp.min.js at 26K or the smaller fxparser.min.js at 20K.
Frequently asked questions
How do I install fast-xml-parser?
Run npm install fast-xml-parser for a project dependency, or npm install fast-xml-parser -g to get the fxparser command on your path. The package is also available from a CDN for use in a web page.
How do I use fast-xml-parser in a Node project?
Import XMLParser, XMLBuilder and XMLValidator from fast-xml-parser, construct an XMLParser, and call parse on your XML data to get a JS object. XMLBuilder does the reverse with its build method.
What is fast-xml-parser?
It is a JavaScript library that validates XML syntactically, parses XML into JS objects and builds XML from JS objects, without C/C++ based libraries and without a callback API. It works in CommonJS, ESM and the browser.
How does fast-xml-parser compare with xml2js?
Both convert XML into JavaScript objects. fast-xml-parser is callback-free, so you construct a parser and call parse synchronously, while xml2js is built around a callback-based API.
What are alternatives to fast-xml-parser?
The README names Flexible-XML-Parser for large or incomplete documents, @nodable/sax as a SAX parser built on it, fast-xml-validator for validation, and fast-xml-builder for building XML. These are separate packages from the same author.
What is fast-xml-parser used for?
It is used to convert XML into JavaScript objects and to build XML from those objects, and to check XML syntax before parsing. The README positions it for CommonJS, ESM and browser use without native libraries.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/naturalintelligence-fast-xml-parser)Star history chart for your README
[](https://hysenlabs.com/projects/naturalintelligence-fast-xml-parser)Was this useful?