# Opsdeck ER Diagram from SQL DDL (SVG, Mermaid) > Turn CREATE TABLE statements into an ER diagram with crow’s foot notation (SVG, Mermaid). Paste PostgreSQL, MySQL or SQLite DDL and get an entity-relationship diagram as SVG: tables with their columns and types, primary, foreign and unique keys, and relationships drawn in crow’s foot notation (one, zero-or-one, zero-or-many). Layered layout along foreign keys or a force-directed layout with a fixed seed, plus a Mermaid erDiagram and a text list of relationships. It is the diagram of the Opsdeck Database desk. Part of usefulweb.app (https://usefulweb.app/). Part of [Opsdeck](https://opsdeck.usefulweb.app/) (ownerApp: opsdeck). Results are deterministic calculations from the inputs and the listed assumptions; the API returns exactly what the web page shows. ## Use it - Human interface: https://opsdeckerdiagram.usefulweb.app/ (interactive tool at https://opsdeckerdiagram.usefulweb.app/tool) - JSON API: POST https://opsdeckerdiagram.usefulweb.app/api/v1/calculate with a JSON object of inputs (schema: https://opsdeckerdiagram.usefulweb.app/api/v1/tool) - OpenAPI: https://opsdeckerdiagram.usefulweb.app/openapi.json - MCP (Streamable HTTP): https://opsdeckerdiagram.usefulweb.app/mcp - tool `opsdeck_er_diagram` ## Inputs - ddl (textarea): Schema (DDL) - CREATE TABLE (and CREATE INDEX / ALTER TABLE) statements. - dialect (select): SQL dialect - layout (select): Layout - seed (integer): Layout seed (force-directed) - The same seed always gives the same picture; try another seed for another arrangement. - showTypes (boolean): Show column types - title (text): Diagram title ## Method - The DDL is read into the same schema model as the Opsdeck schema diff (columns, keys, foreign keys, checks, indexes; ALTER TABLE applied in order). - Layered layout: tables get a rank by the longest chain of foreign keys that point to them (referenced tables left, referencing tables right; cycles are broken at the edge that closes them); four barycentre sweeps order the tables inside each column to reduce crossings. - Force-directed layout: Fruchterman–Reingold with a gravity term and a seeded random start (mulberry32), followed by overlap removal; the same seed gives the same diagram everywhere. - Crow’s foot notation: the referencing side is zero-or-many (zero-or-one when the foreign-key columns are also unique); the referenced side is exactly one when the foreign-key columns are NOT NULL, otherwise zero-or-one.