Can I create json file from a flow chart using d3.js?

Context: I am planning to create a tool which will allow us to create flow chart and then import that flow chart data into a JSON file which can be then utilized in other services.
I am new to js and heard about d3 a lot. So does d3 is capable of doing that? If not are there any other packages/services I can use to accomplish this?

Answer

IMHO d3.js is good at displaying data (hence the name “data driven documents”), however it is not so well suited for creating an editor that lets users “create data from visualizations/documents, that would be “cdv.js” 😉 ).

D3.js does not have a strong graph model and in fact accepts all kinds of data to create a visualization thereof, but there you would have to implement all interactivity that results in the modification or creation of your data (flow chart elements) basically from scratch.

Instead I suggest you take a look at a tool that provides strong diagram editing functionality. A couple of them are listed in this question‘s answers.

With more sophisticated tools like the ones listed there you can create sophisticated diagram editors like this one. They have built-in graph editing capabilities, rather than just graph visualization capabilities.

You can do this on top of d3.js, too, but d3.js will mostly help with the visualization, but not so much with the interactivity.