{"id":39703891,"url":"https://github.com/viveknathani/dbtree","last_synced_at":"2026-01-18T10:30:27.941Z","repository":{"id":331581380,"uuid":"1128383579","full_name":"viveknathani/dbtree","owner":"viveknathani","description":"A tool to visualize database schemas right inside your terminal.","archived":false,"fork":false,"pushed_at":"2026-01-10T17:11:36.000Z","size":898,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-11T01:53:54.355Z","etag":null,"topics":["ascii","database","go","postgresql","schema"],"latest_commit_sha":null,"homepage":"https://vivekn.dev/dbtree/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/viveknathani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-05T14:58:58.000Z","updated_at":"2026-01-10T18:40:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/viveknathani/dbtree","commit_stats":null,"previous_names":["viveknathani/dbtree"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/viveknathani/dbtree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viveknathani%2Fdbtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viveknathani%2Fdbtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viveknathani%2Fdbtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viveknathani%2Fdbtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/viveknathani","download_url":"https://codeload.github.com/viveknathani/dbtree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viveknathani%2Fdbtree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534432,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T10:13:46.436Z","status":"ssl_error","status_checked_at":"2026-01-18T10:13:11.045Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ascii","database","go","postgresql","schema"],"created_at":"2026-01-18T10:30:27.817Z","updated_at":"2026-01-18T10:30:27.913Z","avatar_url":"https://github.com/viveknathani.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dbtree\n\n[![GitHub release](https://img.shields.io/github/v/release/viveknathani/dbtree?color=blue)](https://github.com/viveknathani/dbtree/releases)\n[![Go Report Card](https://goreportcard.com/badge/github.com/viveknathani/dbtree)](https://goreportcard.com/report/github.com/viveknathani/dbtree)\n[![License](https://img.shields.io/badge/license-Unlicense-blue.svg)](UNLICENSE)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/viveknathani/dbtree)](go.mod)\n[![Tests](https://github.com/viveknathani/dbtree/workflows/test/badge.svg)](https://github.com/viveknathani/dbtree/actions)\n\nA tool to visualize database schemas right inside your terminal. It's built for both humans and AI to get complete context of your database architecture.\n\n\u003cimg src=\"demo.gif\" width=\"700\" alt=\"Demo\"\u003e\n\n\u003ci\u003eWorks only with PostgreSQL for now.\u003c/i\u003e\n\n## features\n\n- Visualize table relationships and foreign keys\n- Multiple output formats: `text` or `json`\n- Multiple output shapes: `tree`, `flat`, `chart`\n- Shows columns, data types, and constraints (primary keys, foreign keys, unique constraints)\n- Handles circular references\n\n## installation\n\nLinux/macOS:\n\n```bash\ncurl -fsSL https://vivekn.dev/dbtree/install.sh | bash\n```\n\nOr from source:\n\n```bash\ngit clone https://github.com/viveknathani/dbtree.git\ncd dbtree\nmake build # binary will be created at `./bin/dbtree`\n```\n\nOr using go install:\n\n```bash\ngo install github.com/viveknathani/dbtree/cmd/dbtree@latest\n```\n\n## usage\n\n- `--conn` (required): PostgreSQL connection URL\n\n  - Format: `postgres://username:password@host:port/database`\n  - Example: `postgres://user:pass@localhost:5432/mydb`\n\n- `--format` (optional): Output format\n\n  - `text` (default): Human-readable text output\n  - `json`: Structured JSON output\n\n- `--shape` (optional): Visualization structure\n\n  - `tree` (default): Hierarchical tree showing foreign key relationships\n  - `flat`: Simple list of all tables\n  - `chart`: ASCII diagram of the schema (works with text format only, also see more notes below for this shape)\n\n- `--help`: Display help information\n\n## examples\n\n### Tree View (Text)\n\nShows tables in a hierarchical structure based on foreign key relationships:\n\n```bash\ndbtree --conn \"postgres://user:pass@localhost:5432/mydb\" --format text --shape tree\n```\n\nOutput:\n\n```\ntestdb\n├── categories\n│   ├── id (\"integer\") PRIMARY KEY\n│   ├── name (\"varchar(100)\")\n│   └── description (\"text\")\n│   └── products\n│       ├── id (\"integer\") PRIMARY KEY\n│       ├── name (\"varchar(200)\")\n│       ├── price (\"numeric(10,2)\")\n│       ├── category_id (\"integer\") → categories.id\n│       ├── stock (\"integer\")\n│       └── created_at (\"timestamp\")\n│       ├── order_items\n│       │   ├── id (\"integer\") PRIMARY KEY\n│       │   ├── order_id (\"integer\") → orders.id\n│       │   ├── product_id (\"integer\") → products.id\n│       │   ├── quantity (\"integer\")\n│       │   └── price (\"numeric(10,2)\")\n│       └── reviews\n│           ├── id (\"integer\") PRIMARY KEY\n│           ├── product_id (\"integer\") → products.id\n│           ├── user_id (\"integer\") → users.id\n│           ├── rating (\"integer\")\n│           ├── comment (\"text\")\n│           └── created_at (\"timestamp\")\n└── users\n    ├── id (\"integer\") PRIMARY KEY\n    ├── username (\"varchar(50)\") UNIQUE\n    ├── email (\"varchar(100)\") UNIQUE\n    └── created_at (\"timestamp\")\n    ├── addresses\n    │   ├── id (\"integer\") PRIMARY KEY\n    │   ├── user_id (\"integer\") → users.id\n    │   ├── street (\"varchar(200)\")\n    │   ├── city (\"varchar(100)\")\n    │   ├── country (\"varchar(100)\")\n    │   └── zip_code (\"varchar(20)\")\n    ├── orders\n    │   ├── id (\"integer\") PRIMARY KEY\n    │   ├── user_id (\"integer\") → users.id\n    │   ├── total_amount (\"numeric(10,2)\")\n    │   ├── status (\"varchar(50)\")\n    │   └── created_at (\"timestamp\")\n    │   ├── order_items (see above)\n    │   └── payments\n    │       ├── id (\"integer\") PRIMARY KEY\n    │       ├── order_id (\"integer\") → orders.id\n    │       ├── payment_method (\"varchar(50)\")\n    │       ├── amount (\"numeric(10,2)\")\n    │       ├── status (\"varchar(50)\")\n    │       └── created_at (\"timestamp\")\n    └── reviews (see above)\n```\n\n### Flat List (Text)\n\nLists all tables alphabetically with their columns:\n\n```bash\ndbtree --conn \"postgres://user:pass@localhost:5432/mydb\" --format text --shape flat\n```\n\nOutput:\n\n```\nDatabase: testdb\nTables: 8\n\naddresses\n  - id (integer) PRIMARY KEY\n  - user_id (integer) → users.id\n  - street (varchar(200))\n  - city (varchar(100))\n  - country (varchar(100))\n  - zip_code (varchar(20))\n\ncategories\n  - id (integer) PRIMARY KEY\n  - name (varchar(100))\n  - description (text)\n\norder_items\n  - id (integer) PRIMARY KEY\n  - order_id (integer) → orders.id\n  - product_id (integer) → products.id\n  - quantity (integer)\n  - price (numeric(10,2))\n\norders\n  - id (integer) PRIMARY KEY\n  - user_id (integer) → users.id\n  - total_amount (numeric(10,2))\n  - status (varchar(50))\n  - created_at (timestamp)\n\npayments\n  - id (integer) PRIMARY KEY\n  - order_id (integer) → orders.id\n  - payment_method (varchar(50))\n  - amount (numeric(10,2))\n  - status (varchar(50))\n  - created_at (timestamp)\n\nproducts\n  - id (integer) PRIMARY KEY\n  - name (varchar(200))\n  - price (numeric(10,2))\n  - category_id (integer) → categories.id\n  - stock (integer)\n  - created_at (timestamp)\n\nreviews\n  - id (integer) PRIMARY KEY\n  - product_id (integer) → products.id\n  - user_id (integer) → users.id\n  - rating (integer)\n  - comment (text)\n  - created_at (timestamp)\n\nusers\n  - id (integer) PRIMARY KEY\n  - username (varchar(50)) UNIQUE\n  - email (varchar(100)) UNIQUE\n  - created_at (timestamp)\n```\n\n### Chart View (ASCII Diagram)\n\nRenders an ASCII chart diagram of the schema:\n\n```bash\ndbtree --conn \"postgres://user:pass@localhost:5432/mydb\" --format text --shape chart\n```\n\n\u003cimg src=\"./CHART_EXAMPLE.png\"\u003e\n\n\u003ci\u003eAs of right now, this chart view looks ugly in a terminal and is probably not the best for an AI agent. However, when redirected to a text file, it looks decent enough for humans. I am open to feedback on how this can be improved.\u003c/i\u003e\n\n### JSON Output\n\nExport schema information as structured JSON:\n\n```bash\ndbtree --conn \"postgres://user:pass@localhost:5432/mydb\" --format json --shape tree\n```\n\nOutput:\n\n```json\n{\n  \"database\": \"mydb\",\n  \"tables\": [\n    {\n      \"name\": \"users\",\n      \"columns\": [\n        {\n          \"name\": \"id\",\n          \"type\": \"integer\",\n          \"constraint\": \"PRIMARY KEY\"\n        },\n        {\n          \"name\": \"email\",\n          \"type\": \"character varying\",\n          \"constraint\": \"UNIQUE\"\n        },\n        {\n          \"name\": \"name\",\n          \"type\": \"character varying\"\n        }\n      ],\n      \"children\": [\n        {\n          \"name\": \"posts\",\n          \"columns\": [\n            {\n              \"name\": \"id\",\n              \"type\": \"integer\",\n              \"constraint\": \"PRIMARY KEY\"\n            },\n            {\n              \"name\": \"user_id\",\n              \"type\": \"integer\",\n              \"reference\": \"users.id\"\n            }\n          ]\n        }\n      ]\n    }\n  ]\n}\n```\n\n## hacking\n\nI am open to PRs for improving this project.\n\nYou will need a bunch of things:\n\n1. make\n2. Go (\u003e=v1.25)\n3. PostgreSQL\n\nSome handy commands:\n\n```bash\nmake build\nmake test\n```\n\n## license\n\n[None](./UNLICENSE). Do whatever you want. Have fun and happy hacking!\n\n\u003ci\u003eBuilt by [@viveknathani](https://vivekn.dev)\u003c/i\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviveknathani%2Fdbtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviveknathani%2Fdbtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviveknathani%2Fdbtree/lists"}