# @opendocsg/pdf2md

> A PDF to Markdown Converter

Latest version **0.3.4** (published 2026-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @opendocsg/pdf2md
pnpm add @opendocsg/pdf2md
yarn add @opendocsg/pdf2md
bun add @opendocsg/pdf2md
```

Provides the command `pdf2md`.

## Health

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

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.4 |
| Published | 2026-10-05 |
| First published | 2019-06-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 106 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 500 |
| Author | Open Government Products, Government Technology Agency of Singapore |
| Maintainers | lonerifle, pregnantboy |
| Keywords | PDF, Markdown, Converter |

## Links

- npm: https://www.npmjs.com/package/@opendocsg/pdf2md
- Repository: https://github.com/opendocsg/pdf2md
- Homepage: https://github.com/opendocsg/pdf2md#readme
- Issues: https://github.com/opendocsg/pdf2md/issues
- npm.io page: https://npm.io/package/@opendocsg/pdf2md

## Dependencies (3)

- [unpdf](https://npm.io/package/unpdf.md) ^1.4.0
- [enumify](https://npm.io/package/enumify.md) ^1.0.4
- [minimist](https://npm.io/package/minimist.md) ^1.2.5

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 0.3.4 (latest) — 2026-10-05
- 0.3.3 — 2026-10-05
- 0.3.2 — 2026-09-13
- 0.3.1 — 2026-09-13
- 0.3.0 — 2026-08-25
- 0.2.9 — 2026-08-25
- 0.2.8 — 2026-08-13
- 0.2.7 — 2026-05-28
- 0.2.6 — 2026-04-06
- 0.2.5 — 2026-03-03
- 0.2.4 — 2026-02-19
- 0.2.3 — 2026-01-19
- 0.2.2 — 2025-09-01
- 0.2.1 — 2024-12-12
- 0.2.0 — 2024-11-27
- … 28 more at https://npm.io/package/@opendocsg/pdf2md/versions

## README

# pdf2md

JavaScript npm library to parse PDF files and convert them into Markdown

## Major Changes

See [Releases](https://github.com/opendocsg/pdf2md/releases)

## Usage

### Library

```js
const path = require('path');
const fs = require('fs')
const pdf2md = require('@opendocsg/pdf2md')

const pdfBuffer = fs.readFileSync(filePath)
pdf2md(pdfBuffer, callbacks)
  .then(text => {
    let outputFile = allOutputPaths[i] + '.md'
    console.log(`Writing to ${outputFile}...`)
    fs.writeFileSync(path.resolve(outputFile), text)
    console.log('Done.')
  })
  .catch(err => {
    console.error(err)
  })
```

### CLI tool

```
$ cd [project_folder]
$ npx @opendocsg/pdf2md --inputFolderPath=[your input folder path] --outputFolderPath=[your output folder path] --recursive
```

If you are converting recursively on a large number of files you might encounter the error "Allocation failed - JavaScript heap out of memory”. Instead, run the command

```
$ node lib/pdf2md-cli.js --max-old-space-size=4096 --inputFolderPath=[your input folder path] --outputFolderPath=[your output folder path] --recursive
```

Options:
1. Input folder path (should exist)
2. Output folder path (should exist)
3. Recursive - convert all PDFs for folders within folders. Specify the tag if you require recursive, and omit if you don't

## Credits

[pdf-to-markdown](https://github.com/jzillmann/pdf-to-markdown) - original project by Johannes Zillmann  
[pdf.js](https://mozilla.github.io/pdf.js/) - Mozilla's PDF parsing & rendering platform which is used as a raw parser

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