What ls -R wishes it was
ls -R lists a tree but it's hard to read. tree draws ASCII branches that show structure at a glance. Install with brew install tree on macOS; most Linux distros ship it.
The flags you'll actually use
-L 2— limit depth to 2. Without it, large repos explode.-d— directories only.-a— show hidden.-h— human-readable sizes (with -s or --du).-I 'pattern|other'— ignore matching names. Crucial fornode_modules,.git,__pycache__.--gitignore— respect .gitignore files automatically.
Output formats
tree -J emits JSON. tree -X emits XML. Useful when you want to feed structure to a script or a documentation generator.
Why it matters in practice
When you're explaining a project to a teammate, paste a tree -L 2 -I 'node_modules|.git' output into Slack or a README. Three lines tell more than a paragraph.