# Is there any way to export annotations in Json format in 3D slicer?

**URL:** https://discourse.slicer.org/t/is-there-any-way-to-export-annotations-in-json-format-in-3d-slicer/5198
**Category:** Support
**Created:** [December 27, 2018, 4:31am UTC](https://discourse.slicer.org/t/is-there-any-way-to-export-annotations-in-json-format-in-3d-slicer/5198 "2018-12-27T04:31:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![akhila\_perumalla](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@akhila\_perumalla](https://discourse.slicer.org/u/akhila_perumalla)
#### Post date: [December 27, 2018, 4:31am UTC](https://discourse.slicer.org/t/is-there-any-way-to-export-annotations-in-json-format-in-3d-slicer/5198/1 "2018-12-27T04:31:14Z")

</div>

Operating system: WIndows  
Slicer version: 4.10.0  
Expected behavior:  
Actual behavior:

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [December 27, 2018, 5:10am UTC](https://discourse.slicer.org/t/is-there-any-way-to-export-annotations-in-json-format-in-3d-slicer/5198/2 "2018-12-27T05:10:48Z")

</div>

Yes, you can do it by a few lines of Python code (that you can either copy-paste to the Python console, in a Jupyter notebook, or in a scripted module). For example, export markup fiducials into a json file:

```auto
markupNode = getNode('F')
outputFileName = 'c:/tmp/test.json'

data = []
for fidIndex in range(markupNode.GetNumberOfFiducials()):
  coords=[0,0,0]
  markupNode.GetNthFiducialPosition(fidIndex,coords)
  data.append({'label': markupNode.GetNthFiducialLabel(), 'position': coords})

import json
with open(outputFileName, 'w') as outfile:
  json.dump(data, outfile)

```

---

<div class="post-metadata">

### Author: ![akhila\_perumalla](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@akhila\_perumalla](https://discourse.slicer.org/u/akhila_perumalla)
#### Post date: [December 28, 2018, 1:46am UTC](https://discourse.slicer.org/t/is-there-any-way-to-export-annotations-in-json-format-in-3d-slicer/5198/3 "2018-12-28T01:46:16Z")

</div>

Hi, Can I export segmentation results into json file?

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [December 28, 2018, 2:25am UTC](https://discourse.slicer.org/t/is-there-any-way-to-export-annotations-in-json-format-in-3d-slicer/5198/4 "2018-12-28T02:25:45Z")

</div>

Do you mean writing the 3D voxel array? Of course, it is easily doable, but it would be terribly inefficient.
