Tree Structure Data Generator

Hierarchical JSON trees for visualization demos

Ad placeholder (leaderboard)

Nested data for trees and file explorers

The Tree Structure Data Generator builds hierarchical JSON — the name/children shape used by D3 hierarchies, tree-view components and file-explorer demos. Set the depth and branching factor and it produces either a realistic folder-and-file structure or a generic node tree, with a copyable ASCII preview alongside the JSON.

How it works

The generator recurses from a root at level one. At each level it decides whether the current node is a leaf: if the level has reached your depth limit it becomes a leaf, otherwise it gets between one and your maximum branching factor children, and the function recurses one level deeper for each. A seeded pseudo-random source drives every choice so the same settings reproduce the same tree, while Regenerate advances the seed.

In file-explorer mode, non-leaf nodes are folders carrying a children array and a type of folder, leaves are files with a generated name and extension, and intermediate levels mix in some files so the structure looks realistic. In abstract mode every node is a generic numbered node with an optional children array. The ASCII preview walks the same tree to draw the familiar branch connectors, and a separate pass counts every node so you can see the total size at a glance.

Tips and example

  • Keep depth at three or four and branching at two or three for a tree that stays readable in a visualization.
  • Raise branching for wide, shallow trees (good for dashboards) or raise depth for narrow, deep trees (good for nested-data tests).
  • The ASCII preview is handy for pasting a sample structure straight into documentation or a README.
  • Because the shape is name plus children, you can pass the JSON directly to d3.hierarchy() without remapping fields.
Ad placeholder (rectangle)