DEV Community

Cover image for Windows TREE Command: Map Folders From the Command Line
arnostorg
arnostorg

Posted on

Windows TREE Command: Map Folders From the Command Line

The Windows TREE command prints a folder hierarchy as a text tree. When a project has nested src, tests, docs, and build output, tree shows the shape in one glance — no clicking through Explorer windows.

Microsoft’s reference: TREE command.

What does TREE do?

tree
Enter fullscreen mode Exit fullscreen mode

From the current directory, CMD draws every subdirectory using line characters. Folders nest under parents so you can see depth and structure immediately.

Useful TREE flags

/f — include files

tree /f
Enter fullscreen mode Exit fullscreen mode

Shows folders and files. Perfect for understanding what actually lives in a repo or project folder.

/a — ASCII characters

tree /a
Enter fullscreen mode Exit fullscreen mode

Uses plain +-- style characters instead of box-drawing glyphs. Better for logs, older fonts, and copy-paste into chats that mangle Unicode.

Point at a path

tree C:\Projects\my-app /f
Enter fullscreen mode Exit fullscreen mode

You do not have to cd first — pass the path as an argument.

Practical workflows

Map a project before you change it

cd /d C:\Projects\my-app
tree /f
Enter fullscreen mode Exit fullscreen mode

You will spot leftover node_modules, old dist folders, or misplaced configs fast.

Save a structure snapshot

tree /f > structure.txt
Enter fullscreen mode Exit fullscreen mode

Commit structure.txt in docs, or attach it to a ticket so others see the layout without cloning yet.

Keep output readable

Huge trees (with node_modules) are noisy. Either:

cd src
tree /f
Enter fullscreen mode Exit fullscreen mode

or exclude heavy folders by running TREE from a narrower path.

TREE vs DIR /s

Need Prefer
Visual hierarchy tree / tree /f
Flat recursive file hunt dir /s *.ext
Scriptable name list dir /b /s

Use TREE to understand shape. Use DIR to find or list specific files.

Practice folder mapping hands-on

Once you can read a tree dump, navigating and cleaning projects gets easier.

CMD Master is a free online interactive learning platform for the command line. Learn Windows CMD, PowerShell, and Bash in a browser terminal with instant feedback — no install required. Most lessons are free; the Windows Command Prompt course covers core file and folder skills step by step.

Further reading

Top comments (0)