The i3 window manager allows to save the layout in a JSON file.
This tool converts this JSON file to a DOT file (see GraphViz tool).
To actually visualize the graph, you'll need a viewer like xdot. So the full chain is:
i3-save-tree | i3-layout-to-dot | xdot -
This tool was inspired by this video.
As root:
# npm install -g i3-layout-viewer