xml-formatter

JSON →
library 3.7.0 ·javascript
verified Jun 4, 2026

xml-formatter is a lightweight library (v3.7.0) that converts XML strings into human-readable, pretty-printed format while respecting the xml:space attribute. It also supports minifying formatted XML back to compact strings. The library is zero-dependency, ships TypeScript definitions, and includes a browser bundle. It stands out by preserving xml:space, offering fine-grained formatting options (indentation, line separators, collapse content, filter, ignored paths), and throwing on parse failure by default. Release cadence is moderate; actively maintained. The package bundles for both Node (ESM) and browser (CJS/global). Differentiators: respects xml:space attribute, provides filter and ignoredPaths for selective formatting, and includes minify mode.