# Cytoscape JS format JSON

**URL:** <https://community.neo4j.com/t/cytoscape-js-format-json/58987>\
**Category:** Neo4j Graph Platform\
**Tags:** migrated, visualization-tagged\
**Created:** [July 5, 2021, 10:14pm UTC](https://community.neo4j.com/t/cytoscape-js-format-json/58987 "2021-07-05T22:14:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![D\_C](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/d_c/32/19041_2.png) [@D\_C](https://community.neo4j.com/u/D_C)\
**Post date:** [July 5, 2021, 10:14pm UTC](https://community.neo4j.com/t/cytoscape-js-format-json/58987/1 "2021-07-05T22:14:27Z")

</div>

Hi! I'm trying to render a graph in cytoscape JS which [requires a format](https://js.cytoscape.org/#notation/elements-json) like this, using python server.

```auto
 elements: {
    nodes: [
      {
        data: { id: 'a' }
      },

      {
        data: { id: 'b' }
      }
    ],
    edges: [
      {
        data: { id: 'ab', source: 'a', target: 'b' }
      }
    ]
  },

```

For a simple graph I can convert it myself by walking through the results

As graphs get more complex, picking out the structures will end up getting convoluted to serialize the data in the right way.

I was thinking this should be a common requirement, maybe someone has a better way?

I was looking at the [networkX cytoscape output](https://networkx.org/documentation/stable/_modules/networkx/readwrite/json_graph/cytoscape.html) source code as a reference.

[Using subgraphs](https://community.neo4j.com/t/extracting-subgraph-into-json-format/3416/5) seems it would make all my queries twice as complex, I hope this isn't needed.

---

<div class="post-metadata">

**Author:** ![maheshwar\_ligad](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/maheshwar_ligad/32/3913_2.png) [@maheshwar\_ligad](https://community.neo4j.com/u/maheshwar_ligad)\
**Post date:** [November 16, 2022, 8:11am UTC](https://community.neo4j.com/t/cytoscape-js-format-json/58987/2 "2022-11-16T08:11:12Z")

</div>

[@michael.hunger](https://community.neo4j.com/u/michael.hunger) and [@gg\_lionkhan](https://community.neo4j.com/t5/user/viewprofilepage/user-id/13736) and [@D\_C](https://community.neo4j.com/t5/user/viewprofilepage/user-id/13855) any solution on above issue, Anything work for you. I am looking for similar solution.
