{"id":21033137,"url":"https://github.com/josephuspaye/node-graphviz","last_synced_at":"2025-07-31T12:37:54.857Z","repository":{"id":65411373,"uuid":"281937424","full_name":"JosephusPaye/node-graphviz","owner":"JosephusPaye","description":"A JS + WASM module for compiling graphs written in DOT to images, using GraphViz in Node.js.","archived":false,"fork":false,"pushed_at":"2022-11-09T01:27:22.000Z","size":490,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T13:18:09.631Z","etag":null,"topics":["createweekly","graphviz","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JosephusPaye.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-23T11:50:47.000Z","updated_at":"2024-06-16T09:59:04.000Z","dependencies_parsed_at":"2023-01-23T00:16:00.901Z","dependency_job_id":null,"html_url":"https://github.com/JosephusPaye/node-graphviz","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephusPaye%2Fnode-graphviz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephusPaye%2Fnode-graphviz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephusPaye%2Fnode-graphviz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosephusPaye%2Fnode-graphviz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JosephusPaye","download_url":"https://codeload.github.com/JosephusPaye/node-graphviz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254349398,"owners_count":22056345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["createweekly","graphviz","nodejs"],"created_at":"2024-11-19T12:52:00.555Z","updated_at":"2025-05-15T13:31:41.902Z","avatar_url":"https://github.com/JosephusPaye.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-graphviz\n\nA JS + WASM module for compiling graphs written in DOT to images, using GraphViz in Node.js.\n\nNo annoying native build system or native dependencies that need to be compiled.\n\n## Installation\n\n```\nnpm install node-graphviz --save\n```\n\n## Usage\n\nSee [The DOT Language](https://graphviz.gitlab.io/_pages/doc/info/lang.html) for more information about DOT, and [GraphViz Pocket Reference](https://graphs.grevian.org/example) for some examples.\n\n```js\nconst fs = require('fs');\nconst { graphviz } = require('node-graphviz');\n\n// Define a graph using DOT notation\nconst graph = `\n    digraph {\n        a -\u003e b;\n        b -\u003e c;\n        c -\u003e d;\n        d -\u003e a;\n    }\n`;\n\n// Compile the graph to SVG using the `circo` layout algorithm\ngraphviz.circo(graph, 'svg').then((svg) =\u003e {\n  // Write the SVG to file\n  fs.writeFileSync('graph.svg', svg);\n});\n```\n\nRunning the above produces the following SVG:\n\n![SVG Image showing compiled graph](./tests/output.svg)\n\n## API\n\nThe module exports the following API:\n\n```ts\ndeclare type Format = 'svg' | 'dot' | 'json' | 'dot_json' | 'xdot_json';\n\ndeclare type Engine = 'circo' | 'dot' | 'fdp' | 'neato' | 'osage' | 'patchwork' | 'twopi';\n\nexport declare const graphviz = {\n    layout(dotSource: string, outputFormat?: Format, layoutEngine?: Engine): Promise\u003cstring\u003e;\n    circo(dotSource: string, outputFormat?: Format): Promise\u003cstring\u003e;\n    dot(dotSource: string, outputFormat?: Format): Promise\u003cstring\u003e;\n    fdp(dotSource: string, outputFormat?: Format): Promise\u003cstring\u003e;\n    neato(dotSource: string, outputFormat?: Format): Promise\u003cstring\u003e;\n    osage(dotSource: string, outputFormat?: Format): Promise\u003cstring\u003e;\n    patchwork(dotSource: string, outputFormat?: Format): Promise\u003cstring\u003e;\n    twopi(dotSource: string, outputFormat?: Format): Promise\u003cstring\u003e;\n};\n```\n\n### graphviz.layout(_dotSource_[, _outputFormat_][, _layoutengine_])\n\nPerforms layout for the supplied `dotSource`.\n\nWhere:\n\n- `outputFormat` is one of the following (see [Output Formats](https://graphviz.gitlab.io/_pages/doc/info/output.html) for details):\n  - `dot`\n  - `dot_json`\n  - `json`\n  - `svg` (default)\n  - `xdot_json`\n- `layoutEngine` is one of the following (see [Layout documentation](https://www.graphviz.org/documentation/) for details):\n  - `circo`\n  - `dot` (default)\n  - `fdp`\n  - `neato`\n  - `osage`\n  - `patchwork`\n  - `twopi`\n\n### graphviz.circo(_dotSource_[, _outputFormat_])\n\nConvenience function that performs **circo** layout, is equivalent to `layout(dotSource, outputFormat, 'circo')`.\n\n### graphviz.dot(_dotSource_[, _outputFormat_])\n\nConvenience function that performs **dot** layout, is equivalent to `layout(dotSource, outputFormat, 'dot')`.\n\n### graphviz.fdp(_dotSource_[, _outputFormat_])\n\nConvenience function that performs **circo** layout, is equivalent to `layout(dotSource, outputFormat, 'fdp')`.\n\n### graphviz.neato(_dotSource_[, _outputFormat_])\n\nConvenience function that performs **neato** layout, is equivalent to `layout(dotSource, outputFormat, 'neato')`.\n\n### graphviz.osage(_dotSource_[, _outputFormat_])\n\nConvenience function that performs **osage** layout, is equivalent to `layout(dotSource, outputFormat, 'osage')`.\n\n### graphviz.patchwork(_dotSource_[, _outputFormat_])\n\nConvenience function that performs **patchwork** layout, is equivalent to `layout(dotSource, outputFormat, 'patchwork')`.\n\n### graphviz.twopi(_dotSource_[, _outputFormat_])\n\nConvenience function that performs **twopi** layout, is equivalent to `layout(dotSource, outputFormat, 'twopi')`.\n\n## Credits\n\nThis module is based on [hpcc-systems/hpcc-js-wasm](https://github.com/hpcc-systems/hpcc-js-wasm), which is designed for use in a browser, not Node.js. The following changes were made to support Node and simplify the module to include only GraphViz:\n\n- Rewrote WASM binary location and fetching to read from the filesystem\n- Added the compiled [WASM binary](https://unpkg.com/browse/@hpcc-js/wasm@0.3.14/dist/) to the source\n- Reduced the JS code by half to include only GraphViz, removed Expat and other unrelated code\n- Removed build system and TypeScript, in favor of a single source file (based on the compiled dist file from [hpcc-systems/hpcc-js-wasm](https://github.com/hpcc-systems/hpcc-js-wasm))\n\n## Licence\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosephuspaye%2Fnode-graphviz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosephuspaye%2Fnode-graphviz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosephuspaye%2Fnode-graphviz/lists"}