A developer-focused entry in TopGit's GitHub warehouse: yangshun/tree-node-cli, 293 stars, Developer Tools, TypeScript. List directory contents in a tree-like format, similar to the Linux tree command
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Lists the contents of directories in a tree-like format, similar to the Linux tree command. Both CLI and Node.js APIs are provided.
tree is a command that produces a nicely-formatted indented output of directories and files. When a directory argument is given, tree lists all the files and/or directories found in the given directory.
Note: Symlinks are not followed. Directories that cannot be opened (e.g. due to permission errors) are listed with [error opening dir] instead of crashing, matching Linux tree behavior.
Quickstart
Instantly execute the command in your current directory via npx / pnpx / bunx / yarn dlx:
npx tree-node-cli
Installation
npm install tree-node-cli
# or globally
npm install -g tree-node-cli
[!NOTE]
gitignore is respected by default so node_modules and other common files/directories are excluded automatically. Use --no-gitignore to show them.
CLI
tree [options] [path/to/dir]
[!IMPORTANT]
Use the command treee on Windows and Linux to avoid conflicts with built-in tree command.
The following options are available:
$ tree --help
Usage:
$ tree <command> [options]
Options:
Listing options:
-a, --all-files All files, including hidden files, are printed.
-d, --dirs-only List directories only.
-f, --full-path Print the full path prefix for each file.
-L, --max-depth <n> Max display depth of the directory tree.
-I, --exclude <patterns> Exclude files that match the pattern. | separates
alternate patterns. Wrap your entire pattern in double
quotes. E.g. "node_modules|coverage".
--gitignore Respect .gitignore files (enabled by default).
Use --no-gitignore to disable.
--prune Remove empty directories from output.
File options:
-Q, --quote Quote filenames in double quotes.
-p, --permissions Show file type and permissions.
-s, --sizes Print the size of each file in bytes along with the name.
-h, --human-readable Print file sizes in human-readable format (powers
of 1024). Implies -s.
--si Print file sizes using SI units (powers of 1000).
Implies -s.
--du For each directory report its size as the accumulation
of sizes of all its files and sub-directories. Implies -s.
-D, --date Show last modification time for each entry.
-F, --trailing-slash Append a '/' for directories.
Sorting options:
-v, --version-sort Sort the output by version (natural sort of numbers
within text).
-t, --sort-mtime Sort the output by last modification time.
-c, --sort-ctime Sort the output by last status change time.
-U, --unsorted Do not sort. List files in directory order.
-r, --reverse Sort the output in reverse alphabetic order.
--dirs-first List directories before files.
--files-first List files before directories.
--sort <type> Sort the output by type: name, version, mtime,
ctime, size.
Graphics options:
-i, --no-indent Print entries without tree indentation lines.
-S, --line-ascii Turn on ASCII line graphics.
Output options:
-J, --json Output the tree as a JSON structure.
Misc options:
--help Display this message
--version Display version number
[!TIP]
To exclude the contents of a directory while still printing the directory itself, use a trailing slash with the -I option (e.g., -I "directory/").
For the Node.js API, provide a regex matching the directory contents (e.g., /directory\//). Directories listed in .gitignore (e.g. node_modules) are already excluded by default, use --no-gitignore in combination with -I "directory/" if you want them to show up.
Node.js API
tree(path, options?)
Returns the tree as a formatted string.
import { tree } from 'tree-node-cli';
const string = tree('path/to/dir', {
allFiles: true,
exclude: [/vendor/, /lcov/],
maxDepth: 4,
});
console.log(string);
treeJson(path, options?)
Returns the tree as a structured TreeJsonEntry object (or null if the path is excluded).
// Discriminated union — `contents` only exists on directories
type TreeJsonEntry =
| {
type: 'directory';
name: string;
contents: TreeJsonEntry[];
size?: number;
mode?: string;
time?: string;
}
| { type: 'file'; name: string; size?: number; mode?: string; time?: string };
// size: present when `sizes: true`
// mode: present when `permissions: true`
// time: present when `date: true`
// error: present when the directory could not be opened (e.g. permission denied)
options is a configuration object with the following fields:
Field
Default
Type
Description
allFiles
false
boolean
All files, including hidden files, are printed.
dirsOnly
false
boolean
List directories only.
fullPath
false
boolean
Print the full path prefix for each file.
maxDepth
Number.POSITIVE_INFINITY
number
Max display depth of the directory tree.
exclude
[]
RegExp[]
An array of regex to test each filename against. Matching files will be excluded and matching directories will not be traversed into. To exclude a directory's contents while still showing the directory itself, use a regex that matches the path with a trailing slash (e.g., /vendor\//).
gitignore
true
boolean
Respect .gitignore files when inside a git repository. Use --no-gitignore to disable.
prune
false
boolean
Remove empty directories from output.
quote
false
boolean
Quote filenames in double quotes.
permissions
false
boolean
Show file type and permissions (e.g. [drwxr-xr-x]).
sizes
false
boolean
Print the size of each file in bytes along with the name.
humanReadable
false
boolean
Print file sizes in human-readable format (powers of 1024). Implies sizes.
si
false
boolean
Print file sizes using SI units (powers of 1000). Implies sizes.
du
false
boolean
For each directory, report its size as the accumulation of sizes of all its files and sub-directories. Implies sizes.
date
false
boolean
Show last modification time for each entry.
trailingSlash
false
boolean
Append a / for directories.
sortBy
'name'
string
Sort the output. Options: 'name', 'version', 'mtime', 'ctime', 'size'.
How active is development on yangshun/tree-node-cli?
The most recent commit recorded on yangshun/tree-node-cli was 6 months ago, based on the GitHub push timestamp. The repository has 31 forks — one of the better signals of community interest.
How does yangshun/tree-node-cli compare to other Developer Tools projects?
yangshun/tree-node-cli is tracked by TopGit in the Developer Tools category, with 293 GitHub stars and written in TypeScript. Browse the Developer Tools topic page on TopGit to compare it against similar projects by stars and activity.
How many stars does yangshun/tree-node-cli have?
yangshun/tree-node-cli has 293 GitHub stars — refresh the page for the live number, or check github.com/yangshun/tree-node-cli. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What is yangshun/tree-node-cli?
yangshun/tree-node-cli (yangshun/tree-node-cli) is a TypeScript project on GitHub. From the project's own README: List directory contents in a tree-like format, similar to the Linux tree command
What language is yangshun/tree-node-cli written in?
yangshun/tree-node-cli is written primarily in TypeScript. GitHub's language field is based on the largest share of bytes in the default branch.
What topics is yangshun/tree-node-cli associated with?
GitHub's repository topics for yangshun/tree-node-cli: "cli", "directory", "file", "hacktoberfest", "linux", "node", "tree". TopGit's editorial category is Developer Tools.
Why is yangshun/tree-node-cli categorized under Developer Tools?
TopGit places yangshun/tree-node-cli in the Developer Tools category based on its GitHub topics and description (tagged: "cli", "directory", "file"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Curious whether tree-node-cli is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about tree-node-cli.