# tree-dump

> Tree or binary tree printer, print any tree to terminal or debug window

Latest version **1.1.0** (published 2025-09-04) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install tree-dump
pnpm add tree-dump
yarn add tree-dump
bun add tree-dump
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2025-09-04 |
| First published | 2024-05-01 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10.0 |
| Dependencies | 0 |
| Unpacked size | 16.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | streamich |
| Maintainers | streamich |
| Keywords | tree, print, dump, tree dump, print tree, binary tree, binary search tree |

## Links

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

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2025-09-04
- 1.0.3 — 2025-05-19
- 1.0.2 — 2024-06-24
- 1.0.1 — 2024-05-01
- 1.0.0 — 2024-05-01

## README

# `tree-dump`

Prints a tree structure to the console. Can print a binary tree or a tree with any number of children.

## Usage

Install

```
npm install tree-dump
```

Print a non-binary tree

```js
import {printTree} from 'tree-dump';

const str = 'start' + printTree('', [
  (tab) => 'line 1',
  () => '',
  (tab) => 'line 2' + printTree(tab, [
    (tab) => 'line 2.1',
    (tab) => 'line 2.2',
  ])
  (tab) => 'line 3',
]);

console.log(str);
// start
// ├── line 1
// │
// ├── line 2
// │   ├── line 2.1
// │   └── line 2.2
// └── line 3
```

Print a binary tree

```js
import {printBinary} from 'tree-dump';

const str =
  'Node' +
  printBinary('', [
    (tab) => 'left' + printBinary(tab, [
      () => 'left 1',
      () => 'right 1',
    ]),
    (tab) => 'right' + printBinary(tab, [
      () => 'left 2',
      () => 'right 2',
    ]),
  ]);

console.log(str);
// Node
// ← left
//   ← left 1
//   → right 1
// → right
//   ← left 2
//   → right 2
```

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