Skip to main content

Render directed graphs as ASCII/Unicode art for console output

Project description

graphtty

PyPI downloads PyPI - Version Python versions

Turn any directed graph into colored ASCII art for your terminal.

Installation

pip install graphtty

Deep Agent (ocean theme)

Supervisor Agent (dracula theme)

Quick start

from graphtty import render

graph = {
    "nodes": [
        {"id": "start", "name": "User Input", "type": "entry"},
        {"id": "router", "name": "Router", "type": "condition"},
        {"id": "search", "name": "Web Search", "type": "tool"},
        {"id": "calc", "name": "Calculator", "type": "tool"},
        {"id": "respond", "name": "Respond", "type": "model"},
    ],
    "edges": [
        {"source": "start", "target": "router"},
        {"source": "router", "target": "search", "label": "search"},
        {"source": "router", "target": "calc", "label": "calc"},
        {"source": "search", "target": "respond"},
        {"source": "calc", "target": "respond"},
    ],
}

print(render(graph))
           ┌ entry ─────┐
           │ User Input │
           └─────┬──────┘
                 │
                 ▼
          ┌ condition ──┐
          │   Router    │
          └──────┬──────┘
         ┌search─└──calc───┐
         ▼                 ▼
  ┌ tool ──────┐    ┌ tool ──────┐
  │ Web Search │    │ Calculator │
  └──────┬─────┘    └──────┬─────┘
         └───────┌─────────┘
                 ▼
            ┌ model ──┐
            │ Respond │
            └─────────┘

Nodes support descriptions and nested subgraphs:

# Descriptions appear as extra lines inside the box
{"id": "a", "name": "LLM", "type": "model", "description": "gpt-4o"}

# Nested subgraphs render as boxes within boxes
{"id": "b", "name": "Pipeline", "type": "subgraph", "subgraph": {"nodes": [...], "edges": [...]}}

Apply a color theme:

from graphtty import render, RenderOptions, get_theme

print(render(graph, RenderOptions(theme=get_theme("monokai"))))

CLI

graphtty graph.json
graphtty graph.json --theme monokai
graphtty graph.json --ascii
graphtty graph.json --no-types

Themes

Ten built-in color themes:

default monokai ocean forest dracula solarized nord catppuccin gruvbox tokyo-night

graphtty --list-themes

JSON format

graphtty reads a simple JSON format:

{
  "nodes": [
    { "id": "a", "name": "Start", "type": "entry" },
    { "id": "b", "name": "Process", "type": "tool", "description": "optional detail" },
    { "id": "c", "name": "End", "type": "exit" }
  ],
  "edges": [
    { "source": "a", "target": "b", "label": "optional" },
    { "source": "b", "target": "c" }
  ]
}

Acknowledgements

Built with :heart: on top of grandalf, a Python library for graph layout using the Sugiyama algorithm.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphtty-0.0.5.tar.gz (238.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graphtty-0.0.5-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file graphtty-0.0.5.tar.gz.

File metadata

  • Download URL: graphtty-0.0.5.tar.gz
  • Upload date:
  • Size: 238.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphtty-0.0.5.tar.gz
Algorithm Hash digest
SHA256 994319b9be3a36fe284b74f4bcb99e2b65c3a62cbf797818dbcc456292b04191
MD5 cae2631c8934d13cb3d009d0a606f57a
BLAKE2b-256 37ad21786e42264164750c5524ef4bac22b4756e9c43e464522ae542c3e6da22

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphtty-0.0.5.tar.gz:

Publisher: cd.yml on cristipufu/graphtty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphtty-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: graphtty-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphtty-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7a6bbd5ca0e798a7416afa0e1ae1fde6fea33cc2833c42e01eeec7337e38915b
MD5 9040143120d8adf045c664af0d971f61
BLAKE2b-256 d4a49ed39e8e35c32edc47102de3f97ef4d511025aad69a434867acc623218f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphtty-0.0.5-py3-none-any.whl:

Publisher: cd.yml on cristipufu/graphtty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page