# sdf-parser

> SDF parser

Latest version **9.0.0** (published 2026-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install sdf-parser
pnpm add sdf-parser
yarn add sdf-parser
bun add sdf-parser
```

## Health

**Score 50/100 (C)** — status: active.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 9.0.0 |
| Published | 2026-05-25 |
| First published | 2015-02-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 2 |
| Unpacked size | 63.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Luc Patiny |
| Maintainers | targos, lpatiny, cheminfo-bot, stropitek |
| Keywords | sdf, parser, molfile, v2000, v3000, mdl |

## Links

- npm: https://www.npmjs.com/package/sdf-parser
- Repository: https://github.com/cheminfo/sdf-parser
- Issues: https://github.com/cheminfo/sdf-parser/issues
- npm.io page: https://npm.io/package/sdf-parser

## Dependencies (2)

- [ensure-string](https://npm.io/package/ensure-string.md) ^2.0.0
- [dynamic-typing](https://npm.io/package/dynamic-typing.md) ^2.0.0

## 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

- 9.0.0 (latest) — 2026-05-25
- 8.0.0 — 2026-02-19
- 7.0.5 — 2026-02-16
- 7.0.4 — 2025-03-05
- 7.0.3 — 2025-02-28
- 7.0.2 — 2025-02-27
- 6.0.1 — 2022-10-15
- 6.0.0 — 2022-08-22
- 5.0.2 — 2022-08-17
- 5.0.1 — 2022-03-11
- 5.0.0 — 2021-10-14
- 4.0.2 — 2020-06-27
- 4.0.1 — 2019-06-12
- 4.0.0 — 2019-06-12
- 3.1.0 — 2018-01-26
- … 7 more at https://npm.io/package/sdf-parser/versions

## README

# sdf-parser

[![NPM version][npm-image]][npm-url]
[![build status][ci-image]][ci-url]
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]

Allow to parse a SDF file and convert it to an array of objects.

## Use of the package

```bash
npm install sdf-parser
```

In node script:

```js
// allows to parse a file test.sdf that would be present in the same directory

var { parse } = require('sdf-parser');

var fs = require('fs');
var sdf = fs.readFileSync('./test.sdf', 'utf-8');

var result = parse(sdf);
console.log(result);
```

## require('sdf-parser') (sdf, options)

options:

- exclude : array of string containing the fields to discard
- include : array of string containing the fields to keep
- modifiers : object of functions that need to be converted during the parsing
- filter : function that allows to filter the result
- mixedEOL : if set to true will try to deal with mixed End Of Line separator
- dynamicTyping : convert fields containing only number to numbers (default: true)

## Advanced example with filtering and modifiers

```js
var result = parse(sdf, {
  exclude: ['Number of H-Donors'],
  include: ['Number of H-Donors', 'CLogP', 'Code'],
  modifiers: {
    CLogP: function (field) {
      return {
        low: field * 1 - 0.2,
        high: field * 1 + 0.2,
      };
    },
  },
  filter: (entry) => {
    return entry.CLogP && entry.CLogP.low > 4;
  },
});
```

## Iterator

```js
const { iterator } = require('sdf-parser');
const file = await openAsBlob(join(__dirname, 'test.sdf.gz'));

const decompressionStream = new DecompressionStream('gzip');
const textDecoder = new TextDecoderStream();

const stream = file
  .stream()
  .pipeThrough(decompressionStream)
  .pipeThrough(textDecoder);
const results = [];

for await (const entry of iterator(stream)) {
  results.push(entry);
}
```

## License

[MIT](./LICENSE)

[npm-image]: https://img.shields.io/npm/v/sdf-parser.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/sdf-parser
[ci-image]: https://github.com/cheminfo/sdf-parser/actions/workflows/nodejs.yml/badge.svg
[ci-url]: https://github.com/cheminfo/sdf-parser/actions/workflows/nodejs.yml
[codecov-image]: https://img.shields.io/codecov/c/github/cheminfo/sdf-parser.svg
[codecov-url]: https://codecov.io/gh/cheminfo/sdf-parser
[download-image]: https://img.shields.io/npm/dm/sdf-parser.svg?style=flat-square
[download-url]: https://www.npmjs.com/package/sdf-parser

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