# @file-type/xml

> XML detection plugin for file-type

Latest version **1.1.1** (published 2026-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @file-type/xml
pnpm add @file-type/xml
yarn add @file-type/xml
bun add @file-type/xml
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2026-05-03 |
| First published | 2024-12-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 2 |
| Unpacked size | 16.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Borewit |
| Maintainers | borewit |
| Keywords | file-type, detect, detection, detector, XML, signature, namespace, SVG, XHTML, RSS, KML, GML, MusicXML, plist, property list, xliff, xlf, docbook, TEI, x3d, atom, TTML, SMIL, OPML, MathML, GPX |

## Links

- npm: https://www.npmjs.com/package/@file-type/xml
- Repository: https://github.com/Borewit/file-type-xml
- Homepage: https://github.com/Borewit/file-type-xml#readme
- Issues: https://github.com/Borewit/file-type-xml/issues
- npm.io page: https://npm.io/package/@file-type/xml

## Dependencies (2)

- [sax](https://npm.io/package/sax.md) ^1.6.0
- [strtok3](https://npm.io/package/strtok3.md) ^10.3.5

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2026-05-03
- 1.1.0 — 2026-02-15
- 1.0.0 — 2026-02-14
- 0.5.0 — 2026-02-13
- 0.4.4 — 2025-08-31
- 0.4.3 — 2025-04-24
- 0.4.2 — 2025-04-24
- 0.4.1 — 2025-02-10
- 0.4.0 — 2025-01-16
- 0.3.0 — 2024-12-30
- 0.2.1 — 2024-12-20
- 0.2.0 — 2024-12-19
- 0.1.1 — 2024-12-18

## README

[![NPM version](https://img.shields.io/npm/v/@file-type/xml.svg)](https://npmjs.org/package/@file-type/xml)
[![Node.js CI](https://github.com/Borewit/file-type-xml/actions/workflows/nodejs-ci.yml/badge.svg)](https://github.com/Borewit/file-type-xml/actions/workflows/nodejs-ci.yml)
[![npm downloads](http://img.shields.io/npm/dm/@file-type/xml.svg)](https://npmcharts.com/compare/@file-type/xml?start=365)

# @file-type/xml

Detector plugin for [file-type](https://github.com/sindresorhus/file-type) for XML files.

## Installation

```bash
npm install @file-type/xml
```

## Usage

The following example shows how to add the XML detector to [file-type](https://github.com/sindresorhus/file-type).
```js
import {FileTypeParser} from 'file-type';
import {detectXml} from '@file-type/xml';

const parser = new FileTypeParser({customDetectors: [detectXml]});
const fileType = await parser.fromFile('example.kml');
console.log(fileType);
```

You can also use the XML detector outside [file-type](https://github.com/sindresorhus/file-type):
```js
import {XmlTextDetector} from '@file-type/xml';

const xmlTextDetector = new XmlTextDetector();
xmlTextDetector.write('<svg xmlns="http://www.w3.org/2000/svg"><path fill="#00CD9F"/></svg>');
const fileType = xmlTextDetector.fileType;
console.log(JSON.stringify(fileType)); // Outputs: {"ext":"svg","mime":"image/svg+xml"}
```

## Support file formats

- [XML](https://en.wikipedia.org/wiki/XML) (default for XML, unless a more specific format was detected)
- [Apple Property list, `.plist`](https://en.wikipedia.org/wiki/Property_list)
- [Atom](<https://en.wikipedia.org/wiki/Atom_(web_standard)>)
- [DocBook](https://en.wikipedia.org/wiki/DocBook)
- [GML (Geography Markup Language)](https://en.wikipedia.org/wiki/Geography_Markup_Language)
- [GPX (GPS Exchange Format)](https://en.wikipedia.org/wiki/GPS_Exchange_Format)
- [KML (Keyhole Markup Language)](https://en.wikipedia.org/wiki/Keyhole_Markup_Language)
- [MathML (Mathematical Markup Language)](https://en.wikipedia.org/wiki/MathML)
- [MusicXML, Uncompressed](https://en.wikipedia.org/wiki/MusicXML)
- [OPML (Outline Processor Markup Language)](https://en.wikipedia.org/wiki/OPML)
- [RSS (RDF Site Summary or Really Simple Syndication)](https://en.wikipedia.org/wiki/RSS)
- [SMIL: (Synchronized Multimedia Integration Language)](https://en.wikipedia.org/wiki/Synchronized_Multimedia_Integration_Language)
- [SVG: (Scalable Vector Graphics)](https://en.wikipedia.org/wiki/SVG)
- [TEI, Text Encoding Initiative](https://en.wikipedia.org/wiki/Text_Encoding_Initiative)
- [TTML: (Timed Text Markup Language)](https://en.wikipedia.org/wiki/Timed_Text_Markup_Language)
- [X3D (Extensible 3D)](https://en.wikipedia.org/wiki/X3D)
- [XHTML](https://en.wikipedia.org/wiki/XHTML)
- [XLIFF (XML Localization Interchange File Format)](https://en.wikipedia.org/wiki/XLIFF)

## Licence

This project is licensed under the [MIT License](LICENSE.txt). Feel free to use, modify, and distribute as needed.

---
_Source: https://npm.io/package/@file-type/xml · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
