🌳

Directory Tree Generator

Select a folder and generate a downloadable text directory tree

Directory Tree Generator — what it does

Point the tool at a folder and it walks the entire structure, producing the classic indented text tree — the same format the command-line tree utility prints — ready to download as a TXT file. The browser reads the folder locally through the file API; no listing of your directories ever leaves the machine.

Worked example

A project-handover folder with three subfolders and eight files, selected with the folder picker and generated as text.

Input — the files the browser reports for the selected folder

project-handover/README.md
project-handover/contracts/msa-signed.pdf
project-handover/contracts/sow-2026-q4.pdf
project-handover/design/logo.svg
project-handover/design/mockups/home.png
project-handover/design/mockups/pricing.png
project-handover/src/index.html
project-handover/src/styles.css

Output — tree text (downloaded as directory-tree.txt)

└── project-handover
    ├── README.md
    ├── contracts
    │   ├── msa-signed.pdf
    │   └── sow-2026-q4.pdf
    ├── design
    │   ├── logo.svg
    │   └── mockups
    │       ├── home.png
    │       └── pricing.png
    └── src
        ├── index.html
        └── styles.css

The selected folder itself is the root line, files and folders are listed in the order the browser returns them (no folders-first sorting), and the status shows 8 files.

When this tool helps

  • Documenting a project's layout in a README so newcomers can orient themselves.
  • Recording the structure of a delivery or archive before handing it over, as proof of what was included.
  • Reviewing how a downloads or documents folder actually sprawls before reorganising it.

How to use it

  1. Select the folder to map.
  2. Generate the tree.
  3. Review the indented structure on screen.
  4. Download the TXT file.

Accuracy, limits, and good practice

  • Deeply nested folders with thousands of files produce a very long tree; map the subfolder you care about rather than an entire drive.
  • The tree records names and structure only — no file sizes or dates — which keeps it safe to paste into public documentation.
  • Paste the output into a Markdown code block to preserve the alignment; proportional fonts will otherwise mangle the branches.

Frequently asked questions

Why does the browser ask for permission?

Folder access requires an explicit grant — that is the browser's security model working as intended, once per selection.

Can I exclude folders like node_modules?

There is no exclusion filter, so select a subfolder that avoids them, or delete those branches from the text afterwards.

Why are empty folders missing from the tree?

The folder picker hands the page files, not folders, and the tree is rebuilt from each file's relative path. A folder with nothing in it — or containing only hidden files the picker skips — has no path pointing into it, so it never appears. Put a placeholder file inside if the folder must show.

How can I tell a folder from a file in the output?

Only by indentation: a name with entries indented beneath it is a folder. There is no trailing slash, no size and no file count, and folders are not grouped before files — contracts, design and src sit among README.md in whatever order the browser listed them.

Related tools on this site

Everything above runs inside this page. Directory Tree Generator needs no account, no upload, and no server round trip — close the tab and nothing is left behind.

資料夾目錄樹生成器能做什麼

指定一個資料夾,工具會走訪整個結構,產出經典的縮排文字目錄樹——與命令列 tree 指令相同的格式——並可下載為 TXT。瀏覽器透過檔案 API 在本機讀取資料夾,你的目錄清單不會外流。

實際範例

一個專案交接資料夾,含三個子資料夾與 8 個檔案,透過資料夾選取器選取後產生文字樹。

來源:瀏覽器回報的所選資料夾內檔案

project-handover/README.md
project-handover/contracts/msa-signed.pdf
project-handover/contracts/sow-2026-q4.pdf
project-handover/design/logo.svg
project-handover/design/mockups/home.png
project-handover/design/mockups/pricing.png
project-handover/src/index.html
project-handover/src/styles.css

產生:樹狀文字(可下載為 directory-tree.txt)

└── project-handover
    ├── README.md
    ├── contracts
    │   ├── msa-signed.pdf
    │   └── sow-2026-q4.pdf
    ├── design
    │   ├── logo.svg
    │   └── mockups
    │       ├── home.png
    │       └── pricing.png
    └── src
        ├── index.html
        └── styles.css

所選資料夾本身是第一行根節點;檔案與資料夾依瀏覽器回報的順序排列,不會把資料夾排在前面,狀態列顯示 8 files。

什麼時候用得上

  • 在 README 中記錄專案結構,讓新成員快速上手。
  • 交付檔案或封存前記錄目錄結構,作為內容清單的憑據。
  • 整理下載或文件資料夾前,先看清它實際蔓延成什麼樣子。

使用步驟

  1. 選擇要繪製的資料夾。
  2. 產生目錄樹。
  3. 在畫面上檢視縮排結構。
  4. 下載 TXT 檔案。

精確度、限制與實務建議

  • 巢狀很深、檔案上千的資料夾會產出非常長的樹;請針對真正關心的子資料夾,而不是整顆硬碟。
  • 樹只記錄名稱與結構,不含檔案大小或日期,貼進公開文件也安全。
  • 貼到 Markdown 時請放進程式碼區塊以保住對齊,否則比例字型會把分支弄亂。

常見問題

為什麼瀏覽器會跳出權限詢問?

存取資料夾需要明確授權,這是瀏覽器安全機制的正常運作,每次選取都會詢問一次。

可以排除 node_modules 之類的資料夾嗎?

沒有排除過濾器,請改選避開它們的子資料夾,或事後在文字中刪掉那些分支。

為什麼空資料夾不會顯示在樹裡?

資料夾選取器交給頁面的是檔案而不是資料夾,樹是依每個檔案的相對路徑重建的。裡面沒有東西的資料夾(或只有被選取器略過的隱藏檔)沒有任何路徑指向它,所以不會顯示。一定要顯示的話,放一個佔位檔案進去。

怎麼分辨樹裡的資料夾和檔案?

只能靠縮排:名稱底下有縮排子項的就是資料夾。沒有結尾斜線、沒有大小、也沒有檔案數,資料夾也不會排在檔案前面,contracts、design、src 會和 README.md 混在一起,順序就是瀏覽器回報的順序。

本站相關工具

以上步驟全部在這個頁面內完成,資料夾目錄樹生成器 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。