# @sindresorhus/df

> Get free disk space info from `df -kP`

Latest version **5.0.0** (published 2025-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sindresorhus/df
pnpm add @sindresorhus/df
yarn add @sindresorhus/df
bun add @sindresorhus/df
```

## Health

**Score 55/100 (C)** — status: stable.

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

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2025-09-13 |
| First published | 2015-05-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 9.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 63 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | df, dfkp, df-kp, disk, space, free, info, data, fs, filesystem, file-system, drive, mount, size, capacity |

## Links

- npm: https://www.npmjs.com/package/@sindresorhus/df
- Repository: https://github.com/sindresorhus/df
- Homepage: https://github.com/sindresorhus/df#readme
- Issues: https://github.com/sindresorhus/df/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/@sindresorhus/df

## Dependencies (1)

- [execa](https://npm.io/package/execa.md) ^9.6.0

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

- 5.0.0 (latest) — 2025-09-13
- 4.0.0 — 2021-10-14
- 3.1.1 — 2019-06-30
- 3.1.0 — 2019-03-31
- 3.0.0 — 2019-03-11
- 2.1.0 — 2016-06-16
- 2.0.0 — 2016-04-11
- 1.0.1 — 2015-05-04

## README

# df

> Get free disk space info from [`df -kP`](https://en.wikipedia.org/wiki/Df_\(Unix\))

Works on any Unix-based system like macOS and Linux.

*Created because all the other `df` wrappers are terrible. This one uses simple and explicit parsing. Uses `execFile` rather than `exec`. Ensures better platform portability by using the `-P` flag. Returns sizes in bytes instead of kilobytes and the capacity as a float.*

## Install

```sh
npm install @sindresorhus/df
```

## Usage

```js
import {
	diskSpace,
	diskSpaceForFilesystem,
	diskSpaceForFilesystemOwningPath
} from '@sindresorhus/df';

console.log(await diskSpace());
/*
[
	{
		filesystem: '/dev/disk1',
		type: 'ext4',
		size: 499046809600,
		used: 443222245376,
		available: 55562420224,
		capacity: 0.89,
		mountpoint: '/'
	},
	…
]
*/

console.log(await diskSpaceForFilesystem('/dev/disk1'));
/*
{
	filesystem: '/dev/disk1',
	…
}
*/

console.log(await diskSpaceForFilesystemOwningPath('.'));
/*
{
	filesystem: '/dev/disk1',
	…
}
*/
```

## API

### diskSpace()

Returns a `Promise<object[]>` with a list of space info objects for each filesystem.

### diskSpaceForFilesystem(path)

Returns a `Promise<object>` with the space info for the given filesystem path.

- `filesystem` - Name of the filesystem.
- `type` - Type of the filesystem.
- `size` - Total size in bytes.
- `used` - Used size in bytes.
- `available` - Available size in bytes.
- `capacity` - Capacity as a float from `0` to `1`.
- `mountpoint` - Disk mount location.

#### path

Type: `string`

A path to a [filesystem device file](https://en.wikipedia.org/wiki/Device_file). Example: `'/dev/disk1'`.

### diskSpaceForFilesystemOwningPath(path)

Returns a `Promise<object>` with the space info for the filesystem the given path is part of.

#### path

Type: `string`

A path to a file/directory on the filesystem to get the space info for.

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