tree - Display Directory Structure
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.
Specifying a Directory
If you know where to look, specify the path.

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

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

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

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門
Starting from the Root Directory
You can also start from the root of a drive.
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.
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
| Option | Description |
|---|---|
/F | Also display file names in each directory |
/A | Use 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.
/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.
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.
Practical Examples
Saving the Output to a File
You can save the output of tree with redirection.
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.
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.
Press the Enter key to advance.
Checking a Development Project Structure
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.
| Item | tree | dir |
|---|---|---|
| Display format | Tree structure | List |
| Readability of hierarchy | High | Low |
| File details | Names only | Size, date, attributes, etc. |
| Best for | Checking structure, documentation | Checking details, filtering |
Use tree to see structure and dir to see details.
Summary
This article covered the following points about the tree command.
treedisplays the folder structure in tree form/Falso shows file names/Aswitches to ASCII output- The standard Windows
treehas no option to specify depth or exclusions (useGet-ChildItem -Depthin PowerShell instead) - Use
/Aas well when saving to a file for sharing