tree - Display Directory Structure

Maintained on
Table of Contents

Opening folders one by one in File Explorer to check a folder structure takes time.

The tree command displays the whole directory hierarchy in tree form at once.

It is handy for checking a project layout, pasting a structure into documentation, or recording a layout before a backup.

Quick Reference: Copy-Paste tree Commands

GoalCommand
Show folders onlytree
Include filestree /F
Avoid garbled line characters (ASCII)tree /A
Include files, ASCII characterstree /F /A
Save the result to a text filetree /F /A > tree.txt
Show a specific foldertree /F "C:\Users\user\Documents"

tree has no option to limit the depth or to exclude folders. The formatter below fills both gaps.

Limit Depth and Exclude Folders (Tree Formatter)

Run tree /F /A | clip to copy the tree to the clipboard, then paste it below. Choose how many levels to show and which folder names to drop, and get a tree that is easy to paste into a README or document (├── style, ASCII, or a Markdown list).

Tree formatter (depth limit and exclusions)

Paste the output of tree /F /A to limit the depth, drop folders such as node_modules, and reformat it for a README or document.

Formatted tree
Paste the output of tree /F /A above and the formatted tree appears here.

Everything is processed on this page. Nothing you paste is sent anywhere.

It also reads output with line-drawing characters (without /A) and path lists from dir /s /b.

What Is the tree Command

The tree command graphically displays the directory structure under a specified path.

  • Check a project folder layout at a glance
  • Paste a directory structure into a README or design document
  • Record the folder layout before a backup
  • Quickly check whether subfolders exist

Basic Usage

The syntax of the tree command is as follows.

tree [drive:][path] [/F] [/A]

Without options, it displays the folder structure under the current directory.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>tree
Folder PATH listing for volume Windows
Volume serial number is XXXX-XXXX
C:\USERS\USER
├───Documents
│   ├───Project1
│   └───Project2
├───Downloads
└───Pictures
C:\users\user>

Specifying a Directory

If you know where to look, specify the path.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>tree C:\Users\user\Documents
Folder PATH listing for volume Windows
Volume serial number is XXXX-XXXX
C:\USERS\USER\DOCUMENTS
├───Project1
│   ├───src
│   └───docs
└───Project2
        ├───images
        └───scripts
C:\users\user>

Starting from the Root Directory

You can also start from the root of a drive.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>tree C:\
Beware of Huge Output

Running from the root produces very long output. Narrow the starting path to the range you need.

Can You Limit the Depth?

The only main options of the Windows tree command are /F and /A.

There is no built-in way to specify a depth such as tree -L on Linux.

How to Think About Limiting Depth

To see fewer levels, start from a deeper path. For a tree to paste into a document, output everything and then limit the depth with the tree formatter.

In PowerShell, -Depth of Get-ChildItem limits how many levels are searched.

Get-ChildItem -Recurse -Depth 1

-Depth 1 shows the folder’s direct contents plus one more level. The output is a per-folder list rather than a tree with line characters.

Options of the tree Command

OptionDescription
/FAlso display file names in each directory
/AUse ASCII characters instead of line-drawing characters
/?Display help

/F - Show Files

By default only folders are displayed. With /F, the file names in each folder are shown too.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>tree /F
Folder PATH listing for volume Windows
Volume serial number is XXXX-XXXX
C:\USERS\USER\PROJECT
├───src
│   │   index.js
│   │   app.js
│   └───utils
│                helper.js
└───docs
                README.md
                API.md
C:\users\user>
Useful for README Structure Listings

/F shows folders and files together, which makes it easy to document a project structure.

/A - Use ASCII Characters

The default output uses line-drawing characters. /A switches to ASCII characters.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>tree /A
Folder PATH listing for volume Windows
Volume serial number is XXXX-XXXX
C:\USERS\USER\DOCUMENTS
+---Project1
|   +---src
|   ---docs
---Project2
        +---images
        ---scripts
C:\users\user>
/A Is Easier to Handle in Output Files

When pasting into a text file or Markdown, ASCII characters are less likely to break depending on the environment. Add /A when saving for sharing.

Combining /F /A

To include files and use ASCII characters, combine the options.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>tree /F /A
Folder PATH listing for volume Windows
Volume serial number is XXXX-XXXX
C:\USERS\USER\PROJECT
+---src
|   |   index.js
|   |   app.js
|   ---utils
|                   helper.js
---docs
                README.md
                API.md
C:\users\user>

Practical Examples

Saving the Output to a File

You can save the output of tree with redirection.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>tree C:\Projects\MyApp /F /A > structure.txt

This saves the directory structure to structure.txt. If the path contains spaces, wrap it in double quotes, as in tree "C:\My Projects\MyApp" /F /A.

Add /A for Sharing

When pasting the saved file into email, chat, or Markdown, using /A too helps avoid garbled characters.

Viewing One Screen at a Time

For long output, combine it with more.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>tree C:\ /F | more

Press Space for the next screen or Enter for the next line. Press Q to stop.

Checking a Development Project Structure

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>tree C:\Projects\MyApp /F

Folders with many files, such as node_modules, make the output huge. tree has no exclude option, so start from a narrower path, or paste the output into the tree formatter and exclude folders there.

Finding Specific Files

tree shows the overall structure and cannot filter by name. To search by extension, use dir with subfolder search.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>dir /s /b *.txt

/s includes subfolders, and /b prints only the paths.

Difference from the dir Command

tree and dir both show files and folders, but they are good at different things.

Itemtreedir
Display formatTree structureList
Readability of hierarchyHighLow
File detailsNames onlySize, date, attributes, etc.
Best forChecking structure, documentationChecking details, filtering

Use tree to see structure and dir to see details.

Summary

This article covered the following points about the tree command.

  • tree displays the folder structure in tree form
  • /F also shows file names
  • /A switches to ASCII output
  • The standard Windows tree has no option to specify depth or exclusions (paste the output into the tree formatter to do both)
  • Use /A as well when saving to a file for sharing

Practice Questions

Practice Problem

Which option also displays file names in each folder, not just directories?

Choose one answer.

  1. tree /F
  2. tree /A
  3. tree /D

Practice Problem

Which command is most appropriate for a tree that includes files and uses ASCII characters?

Choose one answer.

  1. tree /L 2
  2. tree /A
  3. tree /F /A
Try more practice questions 171 questions by topic. Answer in your browser and check instantly. Start practicing →
#Command Prompt #Batch File #Command Line #Command #tree #Folder Structure