tree - Display Directory Structure

Maintained on

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.

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>
おすすめ書籍※ 広告を含む場合があります
中小企業経営者のためのRPA入門 RPA導入を成功させる方法

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超入門

60分でわかる! AIエージェント 超入門

コマンドラインの黒い画面が怖いんです。

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

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. If you really need a depth limit, another tool such as PowerShell is more reliable.

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 the Enter key to advance.

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.

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 (use Get-ChildItem -Depth in PowerShell instead)
  • 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?

回答がサーバーに送信されることはありません
Practice Problem

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

回答がサーバーに送信されることはありません
#Command Prompt #Batch File #Command Line #Command #tree #Folder Structure