D3.js Sample Data Generator

Ready-to-use sample data for D3 chart types

Ad placeholder (leaderboard)

A D3.js sample data generator that emits correctly shaped JSON for the most common chart types, so you can prototype a visualization without hand-writing fixtures. It covers bar, line, scatter, pie, treemap, and force graph layouts.

How it works

Pick a chart type and the generator produces data in the exact shape D3 expects. Bar and pie charts get an array of { label, value }. Line charts get a seeded random walk of { date, value } over consecutive days from 2024-01-01, ready for d3.timeParse. Scatter charts get { x, y, group }. Treemaps get a nested hierarchy of a root, group children, and leaves carrying a value. Force graphs get { nodes, links }, where each node after the first links back to an earlier one to guarantee a connected graph, plus a few extra random edges.

Everything is seeded for reproducibility, so the same chart type, point count, and seed yield identical data. The Regenerate button advances the seed.

Tips and example

For a force graph, keep the node count under about 24 so the layout stays legible. The output looks like this:

{
  "nodes": [{ "id": "n0", "label": "Alpha", "group": 2 }],
  "links": [{ "source": "n1", "target": "n0", "value": 3 }]
}

For a treemap, pass the result to d3.hierarchy(data).sum(d => d.value) before running the layout. Use the inline hint under the dropdown as a quick reminder of which D3 helper each shape pairs with, then copy the JSON into your prototype.

Ad placeholder (rectangle)