A Python package and CLI tool that allows you to visualize the complete file and folder structure of any directory. Designed for developers, system administrators, and anyone who wants a clear overview of a project's or folder's structure.
- π³ Recursively traverse directories and display all files and folders
- π Works as a Python library or command-line tool
- ποΈ Optionally include hidden files and folders
- π Multiple output formats:
- Visually formatted tree
- JSON for programmatic use
- πͺΆ Lightweight and dependency-free (optional
richsupport for colorized output) - π Cross-platform (Windows, Linux, macOS)
git clone https://github.com/yourusername/filetree_viewer.git
cd filetree_viewer
pip install -e .pip install filetree-viewerAfter installation, use the CLI to visualize any directory:
# View current directory
filetree-viewer .
# View a specific directory
filetree-viewer /path/to/directory
# Include hidden files
filetree-viewer . --show-hidden
# Output as JSON
filetree-viewer . --jsonfrom filetree_viewer import get_directory_structure, print_tree
# Get and print the directory structure
tree = get_directory_structure(".")
print_tree(tree)
# Output as JSON
json_tree = get_directory_structure(".", as_json=True)
print(json_tree)| Option | Description |
|---|---|
path |
Root directory to scan (default: current directory) |
--json |
Output structure as JSON instead of tree format |
--show-hidden |
Include hidden files and folders (starting with .) |
# Basic usage
filetree-viewer .
# Show hidden files
filetree-viewer . --show-hidden
# Windows path with spaces
filetree-viewer "C:\Program Files\MyApp"
# Output as JSON for parsing
filetree-viewer /home/user/projects --json > structure.jsonπ .
π filetree_viewer
π __init__.py
π __main__.py
π cli.py
π core.py
π utils.py
π LICENSE
π README.md
π requirements.txt
π setup.py
{
"name": ".",
"type": "directory",
"children": [
{
"name": "filetree_viewer",
"type": "directory",
"children": [
{ "name": "__init__.py", "type": "file" },
{ "name": "__main__.py", "type": "file" },
{ "name": "cli.py", "type": "file" },
{ "name": "core.py", "type": "file" },
{ "name": "utils.py", "type": "file" }
]
},
{ "name": "LICENSE", "type": "file" },
{ "name": "README.md", "type": "file" },
{ "name": "requirements.txt", "type": "file" },
{ "name": "setup.py", "type": "file" }
]
}-
Clone the repository:
git clone https://github.com/SHIBINSHA02/filetree_viewer.git cd filetree_viewer -
Install dependencies:
pip install -r requirements.txt
-
Install in editable mode:
pip install -e . -
Run tests (if available):
pytest tests/
filetree_viewer/
βββ filetree_viewer/
β βββ __init__.py
β βββ __main__.py
β βββ cli.py # CLI interface
β βββ core.py # Core logic
β βββ utils.py # Helper functions
βββ tests/
βββ LICENSE
βββ README.md
βββ requirements.txt
βββ setup.py
- Colorized tree view using
richlibrary - Export tree as Markdown or HTML
- Filter by file type (e.g.,
*.py,*.js) - Limit traversal depth
- Respect
.gitignorepatterns - Custom ignore patterns
- File size information
- Last modified timestamps
- Interactive mode
This project is licensed under the MIT License. See the LICENSE file for details.
S Shibinsha
- Email: shibin24888@gmail.com
- GitHub: @SHIBINSHA02
Contributions, issues, and feature requests are welcome!
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Give a βοΈ if this project helped you!
- Basic directory tree visualization
- CLI interface
- Python API
- JSON output support
- Hidden files toggle