Skip to main content

How to Install Tree on MacOS

In this article I will show you how to install the tree command line tool on MacOS.

Step 1. Install brew

If you don't have Homebrew (brew) installed, follow the instructions here:

Update brew

Before installing tree, it's a good idea to update brew first.

Open up a terminal window and run the following command:

brew update

You can also run brew upgrade to update other packages.  But that's not necessary right now and it may take a while.

Step 2. Install tree

Once brew is installed and updated, you can install tree on a Mac with this command.

brew install tree

Step 3. Run tree

To run tree, do the following:

  • Switch to any folder in a Terminal window
  • Run tree in the current folder like this:

To make it more interesting, change to a folder with subfolders

Step 4. View by folder name

To view a folder by name, append the path as an argument like this:

tree ~/Documents

Step 5. View hidden files

To view hidden files, use the -a flag like this:

This example assumes you have Rust installed - you can instead pick any folder with a hidden file like .gitignore or the .git folder.

For this example, create a temporary Rust project:

cargo new rust-temp
  • View only visible files:
tree rust-temp
├── Cargo.toml
└── src
  • Include hidden files and folders
tree -a rust-temp
├── .git
│   ├── HEAD
│   ├── config
│   ├── description
│   ├── hooks
│   │   └── README.sample
│   ├── info
│   │   └── exclude
│   ├── objects
│   │   ├── info
│   │   └── pack
│   └── refs
│   ├── heads
│   └── tags
├── .gitignore
├── Cargo.toml
└── src

Step 6. Tree help

To see what else tree can do, use the --help flag:

tree --help


In this article you learned how to install the tree command line tool on a Mac.

Now you have a useful way of viewing and even documenting the structure of your project folders.