A Go package and CLI to generate ASCII trees from Go programs or Markdown lists, and create/verify directories.
gtree is a Go package and command-line tool that generates ASCII tree diagrams from programmatically defined structures or Markdown unordered lists. It solves the problem of visualizing hierarchical data and automating directory creation based on tree definitions. Beyond simple output, it can create directories, verify existing structures, and export trees in various formats.
Go developers who need to visualize tree structures in their applications, DevOps engineers automating directory scaffolding, and CLI users who want to generate directory trees from Markdown.
Developers choose gtree for its dual approach: a clean Go API for programmatic tree building and a powerful CLI for Markdown-based workflows. Its unique selling point is the ability to not just visualize trees but also create and verify real directory structures, bridging the gap between documentation and filesystem operations.
Easily output ASCII tree from Go program or Markdown unordered list (and it does more than just output tree!🌳🗂🔍)
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The package offers a minimal and intuitive API, as demonstrated by the example where creating and outputting a tree requires just a few lines of code with NewRoot and Add methods.
It seamlessly converts Markdown unordered lists (using *, -, +, #) into tree structures, enabling documentation-driven development and easy CLI usage.
gtree can generate actual directories and files from tree definitions, with support for dry runs and file extensions, effectively bridging documentation and filesystem operations.
Beyond ASCII, it exports trees in JSON, YAML, and TOML formats, facilitating integration with other tools and data serialization workflows.
Offers both simple and pipeline implementations optimized for different data scales, with benchmarks showing efficient handling from small to massive tree sets.
The primary output is ASCII art, lacking support for graphical formats like SVG or PNG, which limits usability in presentations or rich user interfaces.
For programmatic use, it requires Go 1.24 or later, and the CLI relies on Go tooling for installation, making it less accessible in environments without Go or where other languages dominate.
Users must choose between simple and massive modes based on tree size, which adds configuration overhead and risk of performance pitfalls if the wrong mode is selected for the data scale.
Directory creation focuses on basic structure generation; it doesn't handle advanced filesystem attributes like permissions, symlinks, or custom metadata, which are common in complex automation scripts.