# memfs

> In-memory file-system with Node's fs API.

Latest version **4.79.0** (published 2026-09-22) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install memfs
pnpm add memfs
yarn add memfs
bun add memfs
```

## Health

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

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 4.79.0 |
| Published | 2026-09-22 |
| First published | 2015-06-15 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 14 |
| Unpacked size | 72 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2095 |
| Author | streamich |
| Maintainers | streamich |
| Keywords | fs, filesystem, fs.js, memory-fs, memfs, file, file system, mount, memory, in-memory, virtual, test, testing, mock, fsa, file system access, native file system, webfs, crudfs, opfs, casfs, content addressable storage |

## Links

- npm: https://www.npmjs.com/package/memfs
- Repository: https://github.com/streamich/memfs
- Issues: https://github.com/streamich/memfs/issues
- Funding: https://github.com/sponsors/streamich
- npm.io page: https://npm.io/package/memfs

## Dependencies (14)

- [tslib](https://npm.io/package/tslib.md) ^2.0.0
- [thingies](https://npm.io/package/thingies.md) ^2.5.0
- [tree-dump](https://npm.io/package/tree-dump.md) ^1.0.3
- [glob-to-regex.js](https://npm.io/package/glob-to-regex.js.md) ^1.3.1
- [@jsonjoy.com/util](https://npm.io/package/@jsonjoy.com/util.md) ^1.9.0
- [@jsonjoy.com/fs-fsa](https://npm.io/package/@jsonjoy.com/fs-fsa.md) 4.79.0
- [@jsonjoy.com/fs-core](https://npm.io/package/@jsonjoy.com/fs-core.md) 4.79.0
- [@jsonjoy.com/fs-node](https://npm.io/package/@jsonjoy.com/fs-node.md) 4.79.0
- [@jsonjoy.com/fs-print](https://npm.io/package/@jsonjoy.com/fs-print.md) 4.79.0
- [@jsonjoy.com/json-pack](https://npm.io/package/@jsonjoy.com/json-pack.md) ^1.11.0
- [@jsonjoy.com/fs-snapshot](https://npm.io/package/@jsonjoy.com/fs-snapshot.md) 4.79.0
- [@jsonjoy.com/fs-node-utils](https://npm.io/package/@jsonjoy.com/fs-node-utils.md) 4.79.0
- [@jsonjoy.com/fs-node-to-fsa](https://npm.io/package/@jsonjoy.com/fs-node-to-fsa.md) 4.79.0
- [@jsonjoy.com/fs-node-builtins](https://npm.io/package/@jsonjoy.com/fs-node-builtins.md) 4.79.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 4.79.0 (latest) — 2026-09-22
- 5.0.0-next.1 (next) — 2024-04-29
- 4.78.1 — 2026-09-17
- 4.78.0 — 2026-09-13
- 4.77.0 — 2026-09-13
- 4.76.0 — 2026-09-12
- 4.75.0 — 2026-09-11
- 4.74.0 — 2026-09-10
- 4.73.0 — 2026-09-10
- 4.72.2 — 2026-09-10
- 4.72.1 — 2026-09-09
- 4.72.0 — 2026-09-09
- 4.71.1 — 2026-09-09
- 4.71.0 — 2026-09-04
- 4.70.0 — 2026-09-04
- … 251 more at https://npm.io/package/memfs/versions

## README

# memfs

In-memory file system with Node.js `fs` API and browser File System (Access) API.

[![npm][npm-badge]][npm-url]

[npm-badge]: https://img.shields.io/npm/v/memfs.svg
[npm-url]: https://www.npmjs.com/package/memfs

## Overview

`memfs` is a JavaScript library that implements an in-memory file system compatible with Node.js `fs` module and the browser File System (Access) API. Use it for testing, mocking file systems, or creating virtual file systems in both Node.js and browser environments.

## Installation

```bash
npm install memfs
```

## Quick Start

### Node.js `fs` API

```javascript
import { fs } from 'memfs';

// Write a file
fs.writeFileSync('/hello.txt', 'Hello, World!');

// Read a file
const content = fs.readFileSync('/hello.txt', 'utf-8');
console.log(content); // "Hello, World!"

// Create a directory
fs.mkdirSync('/mydir');

// List directory contents
console.log(fs.readdirSync('/')); // ['hello.txt', 'mydir']
```

### Browser File System API

```javascript
import { fsa } from 'memfs';

// Get root directory handle
const root = await fsa.getRoot();

// Create a file
const file = await root.getFileHandle('hello.txt', { create: true });
const writable = await file.createWritable();
await writable.write('Hello, World!');
await writable.close();

// Read the file
const readable = await file.getFile();
const text = await readable.text();
console.log(text); // "Hello, World!"
```

## Features

- Node.js `fs` module API compatibility
- Browser File System (Access) API implementation
- Adapters between `fs` and File System API
- Directory snapshots and tree printing utilities
- Works in Node.js and modern browsers
- TypeScript support

## Documentation

For detailed documentation and more examples, visit the [main project page](https://github.com/streamich/memfs).

## License

Apache 2.0

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