Dagre

Automatic layout engine for directed graphs in JavaScript

Library
npm
v3.1.2
5,835 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
84 /100 Excellent
Development Activity 92
Maintenance 68
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
84 /100 Excellent
Architecture 88
Code Quality 85
Innovation 78
Learning Curve 60

Dagre is a JavaScript library that computes the positions of nodes and edges for directed graphs, so you can render clean, readable diagrams on the client without hand-placing anything. You describe a graph as nodes and edges with sizes and labels, call a single layout function, and Dagre assigns x/y coordinates and edge routing points using a layered (Sugiyama-style) algorithm.

It is rendering-agnostic: Dagre only does the math, leaving you free to draw the result with SVG, Canvas, D3, React, or any other toolkit. This separation is why it underpins many higher-level diagramming tools and flowchart renderers across the ecosystem.

What You Get

  • A single layout(graph) call that assigns x/y coordinates to nodes and routing points to edges
  • Configurable layout direction (top-bottom, left-right), node/edge spacing, and ranking alignment
  • A bundled graphlib Graph data structure for building and querying the input graph
  • Support for compound (nested/cluster) graphs and edge labels that reserve their own space
  • Rendering independence, so results can be drawn with SVG, Canvas, D3, or any framework

Common Use Cases

  • Auto-laying out flowcharts, state machines, and process diagrams
  • Visualizing dependency trees, build graphs, or data pipelines
  • Powering interactive node-and-edge editors and diagramming apps
  • Rendering DAGs such as workflow, org, or provenance graphs

Under The Hood

Architecture - Dagre’s layout() entry point (lib/layout.ts) builds an internal working graph and runs an ordered pipeline of transformation passes over it: makeSpaceForEdgeLabels, acyclic.run (breaks cycles), nestingGraph.run (for compound graphs), rank (assigns nodes to layers via lib/rank/network-simplex.ts), order (crossing minimization using barycenter and median heuristics under lib/order/), position (x-coordinate assignment via the Brandes-Köpf algorithm in lib/position/bk.ts), then edge normalization and denormalization, finally writing coordinates back onto the input graph. Each stage is a small focused module, making the classic Sugiyama layered-drawing method easy to follow end to end.

Tech Stack - Written in TypeScript and compiled with esbuild via build.ts into CJS, ESM, and type-declaration bundles. Its only runtime dependency is @dagrejs/graphlib (the sibling graph data-structure library), keeping the footprint small. Tooling includes Jest for tests, ESLint with typescript-eslint, and tsx for build/version scripts.

Code Quality - The repository carries an extensive test suite (~41 spec files under test/, mirroring the lib/ module layout, including targeted tests for ranking, ordering, and positioning) plus a benchmark harness. Modules are small and single-purpose, types are declared centrally in lib/types.ts, and the layered algorithm’s stages are individually covered, reflecting a mature, well-tested codebase.

API Design - The public surface is deliberately minimal: import dagre, build a Graph, set node/edge/graph labels, and call dagre.layout(g) to have coordinates written in place. This one-call ergonomics is a strength, though most configuration options and examples live in the project wiki rather than the terse in-repo README, which raises the initial discovery curve for newcomers.

Used by 47 apps in this directory

Python
58%
MIT

Docglow

Data Engineering

151

A next-generation documentation site generator for dbt Core projects — lineage explorer, health scoring, and full-text search for teams without access to dbt Cloud's built-in docs features.

View details
69
Repo Health
65
Technical
79
Dependency
Built with
Python 58%
TypeScript 41%
Updated 5 days ago
TypeScript
91%
Other

FastGPT

AI Agents · AI Development

29,900

Build, debug, and deploy knowledge-based AI agents with a visual workflow editor, RAG retrieval, and support for any OpenAI-compatible LLM.

View details
93
Repo Health
84
Technical
66
Dependency
Built with
TypeScript 91%
Updated 5 days ago
TypeScript
53%
Apache 2.0

Flowsint

Automation · Developer Tools

9,911

A privacy-first, graph-based OSINT investigation platform with 30+ automated enrichers for mapping relationships between domains, IPs, people, and organizations.

View details
85
Repo Health
71
Technical
67
Dependency
Built with
TypeScript 53%
Python 45%
Updated 1 weeks ago
Go
87%
MIT

Hatchet

AI Development · Automation · Developer Tools

8,174

A Postgres-backed orchestration engine for background tasks, AI agents, and durable workflows that replaces Redis queues and multi-datastore durable execution platforms with a single self-hostable service.

View details
88
Repo Health
83
Technical
67
Dependency
Built with
Go 87%
Updated 6 days ago
TypeScript
95%
AGPL 3.0

HeyForm

Forms Surveys · No Code Platforms

9,048

Open-source conversational form builder with AI generation, conditional logic, and 30+ integrations — self-host with full data ownership.

View details
86
Repo Health
67
Technical
67
Dependency
Built with
TypeScript 95%
Updated 5 days ago
TypeScript
99%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

483

Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.

View details
90
Repo Health
81
Technical
68
Dependency
Built with
TypeScript 99%
Updated 6 days ago
TypeScript
97%
MIT

HyperDX

Analytics · Developer Tools · Monitoring

9,963

Open source observability platform that unifies logs, traces, metrics, and session replays on ClickHouse — now the core of ClickStack.

View details
89
Repo Health
83
Technical
64
Dependency
Built with
TypeScript 97%
Updated 5 days ago
Rust
72%
Other

iii

Developer Tools · Devops

18,854

Compose, extend, and observe every backend service in real time using three primitives: Workers, Functions, and Triggers.

View details
87
Repo Health
85
Technical
65
Dependency
Built with
Rust 72%
TypeScript 16%
Updated 6 days ago
TypeScript
96%
Other

Infisical

Devops · Security

29,961

The open-source platform for secrets, certificates, privileged access, and AI agent security — all in one self-hostable system.

View details
91
Repo Health
84
Technical
64
Dependency
Built with
TypeScript 96%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers