# JavaScript diagram libraries

JavaScript diagram libraries draw flowcharts, network graphs, and process diagrams in the browser. A diagram library keeps a model of nodes and the edges between them, then lays that model out and renders it as SVG or canvas. These libraries draw the flowcharts in documentation, the process editors in business apps, and the network maps in analysis tools.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [cytoscape](#cytoscape-js) | 100.3M | 11.3K | Nov 2026 | MIT |
| [mermaid](#mermaid) | 98.9M | 91.1K | Nov 2026 | MIT |
| [@viz-js/viz](#viz-js) | 1.9M | 4.4K | Sep 2026 | MIT |
| [bpmn-js](#bpmn-js) | 1.8M | 9.7K | Nov 2026 | bpmn.io license |
| [@antv/g6](#antv-gsix) | 1.2M | 12.4K | May 2026 | MIT |
| [GoJS](#gojs) | 1.1M | 8.5K | Oct 2026 | Commercial |
| [maxGraph](#maxgraph-core) | 519.0K | 1.2K | Oct 2026 | Apache-2.0 |
| [@antv/x6](#antv-xsix) | 368.9K | 6.8K | Aug 2026 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[cytoscape](#cytoscape-js) has the most monthly downloads in this comparison, at 100.3M.

## Capabilities

| Library | Node dragging | SVG export |
| --- | --- | --- |
| [cytoscape](#cytoscape-js) | Yes | Undocumented |
| [mermaid](#mermaid) | No | Yes |
| [@viz-js/viz](#viz-js) | No | Yes |
| [bpmn-js](#bpmn-js) | Yes | Yes |
| [@antv/g6](#antv-gsix) | Yes | No |
| [GoJS](#gojs) | Yes | Yes |
| [maxGraph](#maxgraph-core) | Yes | Yes |
| [@antv/x6](#antv-xsix) | Yes | Via plugin |

## Libraries

### cytoscape

[GitHub](https://github.com/cytoscape/cytoscape.js) · [npm](https://www.npmjs.com/package/cytoscape) · [Docs](http://js.cytoscape.org)

Builds interactive graph visualizations with selectors, layouts, and graph operations.

- Downloads / mo: 100.3M
- Stars: 11.3K
- Last release: 3.35.0
- License: MIT
- Capabilities: [From the cytoscape docs](http://js.cytoscape.org)

**Strengths**

- **Positions graph nodes automatically.** Use layouts to arrange nodes instead of assigning every position.
- **Styles graph elements with selectors.** Apply graph styles using familiar CSS conventions.

**Watch out for**

- **Image export needs a renderer.** Headless graph instances cannot export the currently rendered graph image.
- **Styles ignore CSS specificity.** When selectors overlap, the last matching selector wins.

```sh
npm install cytoscape
```

**kiali/kiali-ui** (208 stars)

[kiali/kiali-ui](https://github.com/kiali/kiali-ui) 

```javascript
private focus(cy: Cy.Core) {
    if (!this.focusSelector) {
      return;
    }

    // only perform the focus one time
    const focusSelector = this.focusSelector;
    this.focusSelector = undefined;

    let selected = cy.$(focusSelector);

    if (!selected) {
      addInfo(
        'Could not focus on requested node. The node may be idle or hidden.',
        true,
        undefined,
        `${focusSelector}`
      );
      return;
    }

    // If there is only one, select it
    if (selected.length === 1) {
      this.selectTargetAndUpdateSummary(selected[0]);
    } else {
      // If we have many elements, try to check if a compound in this query contains everything, if so, select it.
      const compound = selected.filter('$node > node');
      if (compound && compound.length === 1 && selected.subtract(compound).same(compound.children())) {
        this.selectTargetAndUpdateSummary(compound[0]);
        selected = compound;
      }
    }

    // Start animation
    new FocusAnimation(cy).start(selected);
  }

```

[src/components/CytoscapeGraph/CytoscapeGraph.tsx](https://github.com/kiali/kiali-ui/blob/1dcea29a9d7227d81a7018b8e4d227027fe031a0/src/components/CytoscapeGraph/CytoscapeGraph.tsx#L717-L752) · [More projects using cytoscape →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20that%20use%20cytoscape&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import cytoscape from 'cytoscape';

const cy = cytoscape({
  container: document.getElementById('cy'),
  elements: [
    { data: { id: 'a' } },
    { data: { id: 'b' } },
    { data: { id: 'ab', source: 'a', target: 'b' } },
  ],
  layout: { name: 'grid', rows: 1 },
});

```

From [getting-started.md](https://cdn.jsdelivr.net/npm/cytoscape@3.35.0/index.d.ts)

### mermaid

[GitHub](https://github.com/mermaid-js/mermaid) · [npm](https://www.npmjs.com/package/mermaid) · [Docs](https://github.com/mermaid-js/mermaid#readme)

Renders text descriptions into diagrams and visualizations.

- Downloads / mo: 98.9M
- Stars: 91.1K
- Last release: 12.3.0
- License: MIT
- Capabilities: [From the mermaid docs](https://github.com/mermaid-js/mermaid#readme)

**Strengths**

- **Keeps diagrams in text.** Update the diagram description to change the rendered result.
- **Themes individual diagrams.** Apply themes across a site or to individual diagrams.

**Watch out for**

- **Clicks disabled by default.** The default strict security mode disables node click interactions.
- **Custom colors need base theme.** Use the base theme when changing theme variables.

```sh
npm install mermaid
```

**slidevjs/slidev** (49.5K stars)

[slidevjs/slidev](https://github.com/slidevjs/slidev) 

```javascript
export async function renderMermaid(lzEncoded: string, options: any) {
  containerElement ??= document.getElementById('mermaid-rendering-container')!
  const key = lzEncoded + JSON.stringify(options)
  const _cache = cache.get(key)
  if (_cache)
    return _cache

  const code = lz.decompressFromBase64(lzEncoded)

  // custom renderer
  for (const setup of mermaidRenderers) {
    const renderer = await setup()
    if (renderer) {
      const svg = await renderer(code, options)
      cache.set(key, svg)
      return svg
    }
  }

  // fallback: existing mermaid
  mermaid.initialize({
    startOnLoad: false,
    ...clearUndefined(await setupMermaid() || {}),
    ...clearUndefined(options),
  })
  const id = makeId()
  const { svg } = await mermaid.render(id, code, containerElement)
  cache.set(key, svg)
  return svg
}

```

[packages/client/modules/mermaid.ts](https://github.com/slidevjs/slidev/blob/437f139ccd4c8482a193b217922e7800a5b3baec/packages/client/modules/mermaid.ts#L14-L43) · [More projects using mermaid →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20that%20use%20mermaid&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import mermaid from 'mermaid';

mermaid.initialize({ startOnLoad: false });
const { svg } = await mermaid.render('example', 'graph LR; A-->B;');
document.getElementById('diagram').innerHTML = svg;

```

From [usage.html](https://cdn.jsdelivr.net/npm/mermaid@12.3.0/dist/mermaid.d.ts)

### @viz-js/viz

[GitHub](https://github.com/mdaines/viz-js) · [npm](https://www.npmjs.com/package/@viz-js/viz) · [Docs](https://github.com/mdaines/viz-js#readme)

Renders Graphviz diagrams through a WebAssembly build and JavaScript wrapper.

- Downloads / mo: 1.9M
- Stars: 4.4K
- Last release: 3.31.0
- License: MIT
- Capabilities: [From the @viz-js/viz docs](https://github.com/mdaines/viz-js#readme)

**Strengths**

- **Accepts DOT or graph objects.** Pass DOT text or construct a graph object in JavaScript.
- **Reuses the rendering instance.** Render additional graphs without creating another rendering instance.

**Watch out for**

- **Render failures need status checks.** The render method returns failures without throwing for invalid DOT syntax.

```sh
npm install @viz-js/viz
```

**simonw/tools** (1.9K stars)

[simonw/tools](https://github.com/simonw/tools) 

```javascript
async function renderGraph() {
  const dotContent = dotInput.value.trim();
  
  if (!dotContent) {
    output.innerHTML = '';
    return;
  }

  if (!viz) {
    output.innerHTML = '<div class="error">Viz.js is still loading, please wait...</div>';
    return;
  }

  try {
    output.innerHTML = '<div style="color: #666;">Rendering...</div>';
    const svg = await viz.renderSVGElement(dotContent);
    output.innerHTML = '';
    output.appendChild(svg);
  } catch (error) {
    output.innerHTML = `<div class="error"><strong>Error:</strong> ${error.message}</div>`;
  }
}

```

[dot.html](https://github.com/simonw/tools/blob/a285d172df23d622f7cbafdcba978733de244bde/dot.html#L201-L222) · [More projects using @viz-js/viz →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20that%20use%20%40viz-js/viz&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import * as Viz from "@viz-js/viz";

Viz.instance().then(viz => {
  const svg = viz.renderSVGElement("digraph { a -> b }");

  document.getElementById("graph").appendChild(svg);
});

```

From [viz-js.com](https://viz-js.com/api/)

### bpmn-js

[GitHub](https://github.com/bpmn-io/bpmn-js) · [npm](https://www.npmjs.com/package/bpmn-js) · [Docs](https://github.com/bpmn-io/bpmn-js#readme)

Views and edits BPMN 2.0 process diagrams in the browser.

- Downloads / mo: 1.8M
- Stars: 9.7K
- Last release: 18.33.0
- License: bpmn.io license
- Capabilities: [From the bpmn-js docs](https://github.com/bpmn-io/bpmn-js#readme)

**Strengths**

- **Views and edits BPMN diagrams.** Import BPMN XML and edit the process in the browser.

**Watch out for**

- **The watermark must stay visible.** The license forbids removing or covering the bpmn.io watermark on rendered diagrams.

```sh
npm install bpmn-js
```

**camunda/camunda-modeler** (1.7K stars)

[camunda/camunda-modeler](https://github.com/camunda/camunda-modeler) 

```javascript
async exportSVG() {
    const modeler = this.getModeler();

    try {
      const { svg } = await modeler.saveSVG();

      return svg;
    } catch (err) {

      return Promise.reject(err);
    }
  }
```

[client/src/app/tabs/bpmn/BpmnEditor.js](https://github.com/camunda/camunda-modeler/blob/3605bae02897fa55bae6130132303a00ca30f1ab/client/src/app/tabs/bpmn/BpmnEditor.js#L761-L772) · [More projects using bpmn-js →](https://dashboard.exa.ai/playground/search?q=bpmn-js%20GitHub%20projects)

**Quickstart**

```javascript
import Modeler from 'bpmn-js/lib/Modeler';
import 'bpmn-js/dist/assets/diagram-js.css';
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css';

const modeler = new Modeler({ container: '#canvas' });
await modeler.createDiagram();

```

From [Modeler.d.ts](https://cdn.jsdelivr.net/npm/bpmn-js@18.33.0/lib/Modeler.d.ts)

### @antv/g6

[GitHub](https://github.com/antvis/G6) · [npm](https://www.npmjs.com/package/@antv/g6) · [Docs](https://g6.antv.antgroup.com/)

Draws interactive graph visualizations in JavaScript.

- Downloads / mo: 1.2M
- Stars: 12.4K
- Last release: 5.1.1
- License: MIT
- Capabilities: [From the @antv/g6 docs](https://g6.antv.antgroup.com/)

**Strengths**

- **Ships built-in graph layouts.** Arrange nodes with a built-in layout or a custom one.
- **Ships built-in interactions.** Turn on built-in interaction behaviors and listen to graph events.

```sh
npm install @antv/g6
```

**Quickstart**

```javascript
import { Graph } from '@antv/g6';

const graph = new Graph({
  container: 'container',
  data: { nodes: [{ id: 'node-1', style: { x: 100, y: 100 } }] },
});
await graph.render();

```

From [graph.d.ts](https://cdn.jsdelivr.net/npm/@antv/g6@5.1.1/lib/runtime/graph.d.ts) · [Find projects using @antv/g6 →](https://dashboard.exa.ai/playground/search?q=%40antv/g6%20GitHub%20projects)

### GoJS

[GitHub](https://github.com/NorthwoodsSoftware/GoJS) · [npm](https://www.npmjs.com/package/gojs) · [Docs](https://gojs.net)

Builds interactive diagram editors with templates, models, and layouts.

- Downloads / mo: 1.1M
- Stars: 8.5K
- Last release: 4.0.5
- License: Commercial
- Capabilities: [From the GoJS docs](https://gojs.net)

**Strengths**

- **Includes interactive editing tools.** Users can select, drag, copy, delete, pan, and zoom diagram elements.
- **Includes automatic graph layouts.** Choose built-in layouts for trees, force-directed graphs, and layered diagrams.

**Watch out for**

- **Organizations need a commercial license.** Organizational use requires a purchased license beyond private evaluation.
- **SVG exports lose interactivity.** Exported SVG images are static, unlike the interactive diagram.

```sh
npm install gojs
```

**Quickstart**

```javascript
import * as go from 'gojs';

const diagram = new go.Diagram('myDiagramDiv');
diagram.nodeTemplate = new go.Node('Auto').add(
  new go.TextBlock().bind('text', 'key'),
);
diagram.model = new go.GraphLinksModel(
  [{ key: 'Alpha' }, { key: 'Beta' }],
  [{ from: 'Alpha', to: 'Beta' }],
);

```

From [README.md](https://raw.githubusercontent.com/NorthwoodsSoftware/GoJS/master/README.md) · [Find projects using GoJS →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20that%20use%20gojs&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

### maxGraph

[GitHub](https://github.com/maxGraph/maxGraph) · [npm](https://www.npmjs.com/package/@maxgraph/core)

Builds diagrams entirely on the client and renders them with SVG and HTML.

- Downloads / mo: 519.0K
- Stars: 1.2K
- Last release: 0.25.1
- License: Apache-2.0
- Capabilities: [From the maxGraph docs](https://github.com/maxGraph/maxGraph)

**Strengths**

- **Edits vertices and edges.** Resize, move, and rotate shapes, then arrange them with automatic layouts.
- **Reads mxGraph XML.** Load diagrams saved in the mxGraph XML format.

```sh
npm install @maxgraph/core
```

**Quickstart**

```javascript
import { Graph } from '@maxgraph/core';
import '@maxgraph/core/css/common.css';

const graph = new Graph(document.getElementById('graph'));
graph.batchUpdate(() => {
  graph.insertVertex({
    parent: graph.getDefaultParent(),
    value: 'Hello',
    position: [20, 20],
    size: [80, 30],
  });
});

```

From [README.md](https://cdn.jsdelivr.net/npm/@maxgraph/core@0.25.1/lib/esm/view/mixin/VertexMixin.type.d.ts) · [Find projects using maxGraph →](https://dashboard.exa.ai/playground/search?q=%40maxgraph/core%20GitHub%20projects)

### @antv/x6

[GitHub](https://github.com/antvis/X6) · [npm](https://www.npmjs.com/package/@antv/x6) · [Docs](https://x6.antv.antgroup.com/tutorial/about)

Builds diagram editors that render with SVG and HTML.

- Downloads / mo: 368.9K
- Stars: 6.8K
- Last release: 3.1.8
- License: MIT
- Capabilities: [From the @antv/x6 docs](https://x6.antv.antgroup.com/tutorial/about)

**Strengths**

- **Exports SVG and images.** Export a graph as SVG, PNG, or JPEG through the Export plugin.

**Watch out for**

- **Export needs a plugin.** SVG and image export load through the separate Export plugin.

```sh
npm install @antv/x6
```

**Quickstart**

```javascript
import { Graph } from '@antv/x6';

const graph = new Graph({
  container: document.getElementById('graph'),
  width: 600,
  height: 400,
});
graph.addNode({
  shape: 'rect', x: 40, y: 40, width: 80, height: 40,
  attrs: { label: { text: 'Hello' } },
});

```

From [graph.d.ts](https://cdn.jsdelivr.net/npm/@antv/x6@3.1.8/lib/graph/graph.d.ts) · [Find projects using @antv/x6 →](https://dashboard.exa.ai/playground/search?q=%40antv/x6%20GitHub%20projects)

## FAQ

### What is Mermaid.js?

[Mermaid](#mermaid) is a JavaScript tool that renders diagrams, charts, and visualizations from a Markdown-based text syntax. Update the diagram description to change the rendered result.

### What is GoJS, and does it need a license?

[GoJS](#gojs) is a JavaScript and TypeScript library for creating and manipulating diagrams, charts, and graphs. Organizational use requires a purchased license beyond private evaluation.

### What are the alternatives to GoJS?

[maxGraph](#maxgraph-core) and [@antv/x6](#antv-xsix) build editable diagrams in the browser with SVG and HTML rendering. [bpmn-js](#bpmn-js) covers BPMN process diagrams.

### What is the difference between Mermaid and Graphviz?

[Mermaid](#mermaid) compiles its own Markdown-based diagram languages to SVG, while [Viz.js](#viz-js) renders Graphviz DOT text through a WebAssembly build of Graphviz.

### What is Cytoscape.js?

[Cytoscape.js](#cytoscape-js) is a graph theory library for network analysis and visualization, with layouts that position nodes automatically.

### How does Viz.js report a rendering error?

The render method returns failures without throwing for invalid DOT syntax.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "JavaScript diagram libraries Mermaid Cytoscape Viz Graphviz GoJS layout interactions code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
