{"id":22423296,"url":"https://github.com/prantlf/graphviz-cli","last_synced_at":"2025-08-01T07:32:09.164Z","repository":{"id":57253764,"uuid":"271862187","full_name":"prantlf/graphviz-cli","owner":"prantlf","description":"Graphviz graph image generator as command-line tool using Node.js and WASM","archived":false,"fork":false,"pushed_at":"2022-12-11T09:45:37.000Z","size":138,"stargazers_count":12,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-30T15:07:00.447Z","etag":null,"topics":["dot","graph","graphviz"],"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/prantlf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-06-12T18:11:29.000Z","updated_at":"2024-06-16T10:01:27.000Z","dependencies_parsed_at":"2023-01-26T20:30:24.113Z","dependency_job_id":null,"html_url":"https://github.com/prantlf/graphviz-cli","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fgraphviz-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fgraphviz-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fgraphviz-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fgraphviz-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prantlf","download_url":"https://codeload.github.com/prantlf/graphviz-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228348371,"owners_count":17905899,"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":["dot","graph","graphviz"],"created_at":"2024-12-05T18:09:55.333Z","updated_at":"2024-12-05T18:09:55.986Z","avatar_url":"https://github.com/prantlf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphviz-cli\n\n[![npm](https://img.shields.io/npm/v/graphviz-cli)](https://www.npmjs.com/package/graphviz-cli#top)\n[![codecov](https://codecov.io/gh/prantlf/graphviz-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/prantlf/graphviz-cli)\n[![codebeat badge](https://codebeat.co/badges/9d85c898-df08-42fb-8ab9-407dc2ce2d22)](https://codebeat.co/projects/github-com-prantlf-graphviz-cli-master)\n![Dependency status](https://img.shields.io/librariesio/release/npm/graphviz-cli)\n\nCommand-line tool and [API] for generating graph images from [Graphviz] source scripts.\n\nFeatures:\n\n* Runs in pure JavaScript. Except for the `png` output.\n* No need to install the native [Graphviz] package.\n* Most output formats of the native [Graphviz] (inluding `svg` and `png`) available.\n* TypeScript type declarations (typings) for the [API].\n* [A lot faster](perf/README.md) then calling `dot` as a separate process.\n\nUses [@aduh95/viz.js] to render [Graphviz] scripts in pure JavaScript by [WASM]. Uses [node-canvas] for the optional `png` output.\n\nRelated tools:\n\n* [graphviz-builder] - generates the source script for [Graphviz] consumable by this tool\n* [graphviz-webcomponent] - WebComponent for web browsers to display graph images from the source scripts in HTML pages on-the-fly\n\n## Synopsis\n\n```\ngraphviz -Tsvg -ohello.svg hello.dot\n```\n\n```js\nimport { renderGraphFromSource } from 'graphviz-cli'\n// Render a string with the graph script to a string with the SVG output.\nconst svg = await renderGraphFromSource({ input: 'graph G { ... }' }, { format: 'svg' })\n// Render a file with a graph script to a file with the PNG output.\nawait renderGraphFromSource({ name: 'hello.dot' }, { format: 'png', name: 'hello.png' })\n```\n\n## Installation\n\nMake sure that you have installed [Node.js] 14.8 or newer.\n\nIf you want to use the command-line tool, install this package globally using your favourite package manager ([NPM], [Yarn] or [PNPM]):\n\n```\nnpm i -g graphviz-cli\nyarn global add graphviz-cli\npnpm i -g graphviz-cli\n```\n\nIf you want to use this package programmatically, install it locally using your favourite package manager. Add `-D` on the command line if you need the tool only to build you package:\n\n```\nnpm i graphviz-cli\nyarn add graphviz-cli\npnpm i graphviz-cli\n```\n\nIf you want to render graphs to `png`, install the [node-canvas] module in addition. Add `-g/global` or `-D` arguments according to you choice above:\n\n```\nnpm i canvas\nyarn add canvas\npnpm i canvas\n```\n\nStarting from the version 2.0.0, [node-canvas] is not a peer dependency any more, because NPM installs the peer dependencies automatically, making them not optional any more.\n\n## Command-line\n\nCommand-line parameters are the same as for the `dot` tool from the [Graphviz] package, as long as they are implemented, of course.\n\n```\n$ graphviz -?\n\nGenerates graph images from Graphviz source scripts.\n\nUsage: graphviz [-Vvy?] [-(KTon)\u003cvalue\u003e] \u003cdot files\u003e\n\nOptions:\n  -Tv           - set output format to 'v'\n  -Kv           - set layout engine to 'v' (overrides source script)\n  -ofile        - write output to 'file'\n  -O            - automatically generate an output filename based on the input\n                  filename with a .'format' appended. (Causes all -ofile\n                  options to be ignored.)\n  -y            - invert y coordinate in output\n  -n[v]         - no layout mode 'v' (=1)\n  -v            - enable verbose mode\n  -V            - print version and exit\n  -?            - print usage and exit\n\nExamples:\n  graphviz -Tsvg -O diagrams/*.dot\n  graphviz -Tpng -Kneato -odiagram.png diagram.dot\n```\n\n## API\n\n### renderGraphFromSource(source: object, options: object): Promise\\\u003cstring | Buffer\\\u003e\n\nRenders a graph script to a specified output. If the output format is binary (`png`, for example), the Promise will contain `Buffer` instead of `string`.\n\n```js\nimport { renderGraphFromSource } from 'graphviz-cli'\n// Render a string with the graph script to a string with the SVG output.\nconst svg = await renderGraphFromSource({ input: 'graph G { ... }' }, { format: 'svg' })\n// Render a file with a graph script to a file with the PNG output.\nawait renderGraphFromSource({ name: 'hello.dot' }, { format: 'png', name: 'hello.png' })\n```\n\nSource properties:\n\n|  name   |  type    | description                     |\n|---------|----------|---------------------------------|\n| `name`  | `string` | file name with the graph script |\n| `input` | `string` | graph script                    |\n\nIf neither `name` nor `input` are provided, or the whole `source` parameter is omitted, the graph script will be read from the standard input.\n\nAvailable options:\n\n|  name     |  type     | description                                 |\n|-----------|-----------|---------------------------------------------|\n| `name`    | `string`  | file name for the generated graph output    |\n| `engine`  | `string`  | type of the layout to use for the graph rendering (`circo`, `dot`, `fdp`, `neato`, `osage`, `twopi`, default is `dot`)                   |\n| `format`  | `string`  | type of the output for the rendered graph (`svg`, `png`, `dot`, `xdot`, `plain`, `plain-ext`, `ps`, `ps2`, `json`, `json0`, `canon`, default is `dot`) |\n| `yInvert` | `boolean` | invert the y-coordinate in the graph output |\n| `nop`     | `number`  | no layout mode 'v' (`0` or `1`)             |\n\nIf `name` is not provided the output will be available only in the Promise. If the format `png` is specified, the NPM module [node-canvas] has to be installed in addition to this package.\n\n### engines\n\nList of available graph layout engines: `circo`, `dot`, `fdp`, `neato`, `osage`, `twopi`.\n\n### formats\n\nList of available graph outout formats: `svg`, `png`, `dot`, `xdot`, `plain`, `plain-ext`, `ps`, `ps2`, `json`, `json0`, `canon`.\n\n## License\n\nCopyright (c) 2020-2022 Ferdinand Prantl\n\nLicensed under the MIT license.\n\n[Graphviz]: https://graphviz.org/\n[WASM]: https://developer.mozilla.org/en-US/docs/WebAssembly\n[@aduh95/viz.js]: https://github.com/aduh95/viz.js#readme\n[node-canvas]: https://github.com/Automattic/node-canvas#readme\n[graphviz-builder]: https://github.com/prantlf/graphviz-builder#readme\n[graphviz-webcomponent]: https://github.com/prantlf/graphviz-webcomponent#readme\n[Node.js]: https://nodejs.org/\n[NPM]: https://docs.npmjs.com/cli/npm\n[Yarn]: https://classic.yarnpkg.com/docs/cli/\n[PNPM]: https://pnpm.js.org/pnpm-cli\n[API]: #api\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fgraphviz-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprantlf%2Fgraphviz-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fgraphviz-cli/lists"}