
Security News
The Nightmare Before Deployment
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.
tree2repo
Advanced tools
Create a project directory structure from a pasted tree printed by a tool, an editor, or an AI model.
Instead of clicking New folder fifty times, you paste a tree and let this tool create all folders and files for you.
pip install tree2repo
Assume you are inside a directory where you want to generate your project:
cd my_project_root
tree2repo << 'EOF'
my_project_root/
src/
my_package/
__init__.py
core.py
tests/
test_core.py
README.md
pyproject.toml
EOF
Result:
my_project_root/ is ignored by default.my_project_root you will now have:src/
my_package/
__init__.py
core.py
tests/
test_core.py
README.md
pyproject.toml
This is ideal when you get a tree for a repository but you are already standing at the intended root.
If you actually want the top-level folder to be created, use --respect-root:
cd /tmp
tree2repo --respect-root << 'EOF'
my_project_root/
src/
my_package/
__init__.py
core.py
tests/
test_core.py
README.md
pyproject.toml
EOF
Now you get:
my_project_root/
src/
my_package/
__init__.py
core.py
tests/
test_core.py
README.md
pyproject.toml
You can tell tree2repo to create the structure somewhere else using --root:
tree2repo --root /tmp/new_project << 'EOF'
my_project_root/
src/
my_package/
__init__.py
core.py
README.md
EOF
With default settings, the top-level label is ignored, so the files end up directly under /tmp/new_project.
tree2repo expects a very simple, whitespace-indented format:
/.Example:
my_project_root/
src/
my_package/
__init__.py
core.py
tests/
test_core.py
README.md
Notes:
You can also use tree2repo directly from Python.
from tree2repo import create_from_tree
tree = """my_project_root/
src/
my_package/
__init__.py
core.py
README.md
"""
# Create under "./generated" and ignore the top-level label "my-project/"
create_from_tree(tree_text=tree, root="./generated", ignore_root_label=True)
Arguments:
tree_text: the indented tree as a single string.root: directory where the structure should be created.ignore_root_label: when true, skips the first top-level directory label.mkdir(parents=True, exist_ok=True), so existing directories are reused.touch semantics (existing files are left as they are)./) is treated as a label and skipped when ignore_root_label is true.--respect-root in the CLI, ignore_root_label is set to false and the top-level folder is created.cd my_package_root
tree2repo << 'EOF'
example-project/
src/
example_package/
__init__.py
cli.py
tests/
test_cli.py
pyproject.toml
README.md
EOF
You now have a ready-made layout to start turning into a real package.
from tree2repo import create_from_tree
skeleton = """example-project/
src/
example_package/
__init__.py
api.py
tests/
test_api.py
create_from_tree(skeleton, root=".", ignore_root_label=True)
If you want to work on tree2repo itself:
git clone https://github.com/akshan-main/tree2repo.git
cd tree2repo
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install -e .
Run tests (if you add or modify them):
pytest
Current focus is deliberately small:
├──, │, and so on).Potential future improvements:
For now, tree2repo is meant to solve a very specific irritation: turning a pasted tree into a real project skeleton in a single command.
FAQs
Create a repo structure from a pasted tree.
We found that tree2repo demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.

Research
/Security News
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.