Share a Cytoscape.js network graph as a link
A Cytoscape.js graph draws in the browser, so it fits in one HTML file. Load Cytoscape from a CDN, put the nodes and edges in the page, upload the file, and send a link that opens the working graph.
Cytoscape.js draws network graphs in the browser: nodes, edges, layouts, and pan, zoom and drag. A screenshot keeps none of that, and a page that loads its graph from a separate JSON file breaks when the recipient opens it from disk, because a request for a local file is blocked on a file:// page.
One HTML file with Cytoscape loaded from a CDN and the graph data inside it, hosted at a link, opens the working graph on any device.
Put the graph in one file
Create graph.html with this structure:
- ✓<!doctype html>, <meta charset="utf-8"> and <meta name="viewport" content="width=device-width, initial-scale=1"> in the head.
- ✓One script tag with a pinned version: https://cdn.jsdelivr.net/npm/cytoscape@3.35.0/dist/cytoscape.min.js.
- ✓A container with a height, such as <div id="cy" style="width:100%;height:500px"></div>. Cytoscape fills the container, so a container with no height shows nothing.
- ✓A <script> block after the container that calls cytoscape({ container: document.getElementById("cy"), elements: [...], style: [...], layout: { name: "breadthfirst" } }).
- ✓Each node is { data: { id: "a", label: "Web" } } and each edge is { data: { source: "a", target: "b" } }. Add a style rule for node with label: "data(label)" to show the labels.
- ✓Tested on Cytoscape.js 3.35.0: three nodes and two edges drew with the breadthfirst layout. Built-in layouts include grid, circle, concentric, breadthfirst and cose; others, such as dagre or cola, are extensions with their own script tags.
Keep the data inside the page
A graph that loads its elements with fetch("graph.json") requests a second file. An uploaded page is hosted on its own, so that request fails and the graph stays empty.
Paste the elements array into the script. Cytoscape desktop can export a network as Cytoscape.js JSON; its elements can go into the page the same way.
Every edge must point at node ids that exist. An edge with a missing target stops the graph with the error "Can not create edge ... with nonexistent target".
Upload it and send the link
Drag the .html file onto the FileShare Pro dashboard and copy the link. The graph draws when the page opens, viewers can pan, zoom and drag nodes, and they need no account.
If the page is blank once hosted, open the browser console. "cytoscape is not defined" means the script tag is missing or comes after your graph code; a failed request for a .json file means data was left outside the page. Why an AI page works in chat but breaks when hosted covers graphs an assistant wrote.
Turn on comments and viewers can leave a note on the page after typing a name. When the graph changes, upload the new file over the old one and the link stays the same: updating a shared link without changing it.
Other graph and diagram tools: pyvis and NetworkX, Graphviz, Mermaid, D3.
Frequently asked
Put the Cytoscape script tag, a container with a height, your elements and the cytoscape() call into one HTML file, upload it to a host that serves HTML as a web page, and send the link.
Usually the container has no height, the script tag is missing or loads after the graph code, an edge points at a node id that does not exist, or the elements come from a file that was not uploaded. Check the browser console for the exact error.
Yes. The hosted page runs the same JavaScript as your local file, so viewers can pan, zoom and drag nodes. Positions reset when the page reloads.
Yes. The free plan hosts up to 50 files of up to 100 MB each, with view counts and comments included. Password-protected links are on Pro.
Drop the file, copy the link — live in seconds, free plan included.
Start sharing free