npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

folder-tree-md

v1.0.1

Published

Fast, zero-dependency CLI & TypeScript library to generate clean Markdown directory trees for READMEs and documentation.

Readme

📁 folder-tree-md

Fast, zero-dependency CLI & TypeScript library to generate clean Markdown directory trees for READMEs, documentation, and technical architecture docs.

npm version License: MIT Sponsor TypeScript


✨ Features

  • ⚡ Zero Dependencies — Ultra-fast, lightweight, pure native Node.js and TypeScript.
  • 💻 CLI & Programmatic API — Run directly via npx folder-tree-md or import in your build scripts.
  • 🛡️ Auto-Ignores Bloat — Automatically skips node_modules, .git, dist, .next, build, and parses .gitignore.
  • 🎚️ Depth Control — Limit recursion depth easily with -d <depth>.
  • 📁 Directories Only Mode — Focus exclusively on folder architecture.
  • 📊 File Size Display — Optional human-readable file sizes ([1.2 KB]).
  • 📝 Markdown Ready — Generates formatted ```text ... ``` code blocks ready to paste into README.md.
  • 💾 Save to File — Directly export trees into .md or text files with -o <path>.

📥 Installation

As a CLI Tool (Recommended)

You can run it instantly without installation:

npx folder-tree-md

Or install globally:

npm install -g folder-tree-md

As a Project Dependency (Library)

npm install folder-tree-md

🚀 CLI Usage

Basic Usage

Generate tree for the current directory:

npx folder-tree-md

Output Example

my-project/
├── src/
│   ├── components/
│   │   ├── Button.tsx
│   │   └── Card.tsx
│   ├── utils/
│   │   └── helper.ts
│   └── index.ts
├── tests/
│   └── index.test.ts
├── package.json
├── tsconfig.json
└── README.md

Useful CLI Examples

Limit Traversal Depth:

npx folder-tree-md . -d 2

Directories Only:

npx folder-tree-md . --dirs-only

Include File Sizes:

npx folder-tree-md ./src -s

Custom Ignore Patterns:

npx folder-tree-md . -i "*.log,temp,coverage"

Save Output Directly to Markdown File:

npx folder-tree-md . -o PROJECT_STRUCTURE.md

💻 Programmatic API Usage

You can also import and use it in your Node.js or TypeScript scripts:

import { generateTree, getTreeData } from 'folder-tree-md';

// 1. Generate formatted markdown tree string
const markdownTree = generateTree('./src', {
  maxDepth: 3,
  wrapMarkdown: true,
  dirsOnly: false,
  showSize: true,
});

console.log(markdownTree);

// 2. Or get hierarchical JSON data structure
const treeData = getTreeData('./src');
console.log(JSON.stringify(treeData, null, 2));

⚙️ CLI Options Reference

| Flag | Long Flag | Description | |---|---|---| | -d | --max-depth <n> | Maximum recursion depth (e.g. 1, 2, 3). | | -i | --ignore <patterns> | Comma-separated patterns to ignore. | | | --dirs-only | Only output directories, skip files. | | | --hidden | Include hidden files and folders (.env, .config, etc.). | | -s | --size | Include formatted file sizes (e.g., [1.2 KB]). | | | --raw | Output plain tree without Markdown ```text fence. | | | --json | Output full JSON data tree structure. | | -o | --output <file> | Write tree directly to a file. | | -v | --version | Display current version. | | -h | --help | Display help and usage information. |


🛠 Development & Testing

# Install dependencies
npm install

# Run unit tests
npm test

# Build dual ESM/CJS bundles + CLI executable + .d.ts types
npm run build

💖 Support the Project

If you find this package useful, consider sponsoring its ongoing development and maintenance: 👉 Sponsor @Piratha97 on GitHub Sponsors

📄 License

MIT © 2026 Pirapaakaran Pirathapan