# Export map grid as C array

**URL:** <https://discourse.mapeditor.org/t/export-map-grid-as-c-array/3861>\
**Category:** Questions\
**Created:** [April 2, 2019, 9:07pm UTC](https://discourse.mapeditor.org/t/export-map-grid-as-c-array/3861 "2019-04-02T21:07:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jenkins](https://avatars.discourse-cdn.com/v4/letter/j/d9b06d/32.png) [@jenkins](https://discourse.mapeditor.org/u/jenkins)\
**Post date:** [April 2, 2019, 9:07pm UTC](https://discourse.mapeditor.org/t/export-map-grid-as-c-array/3861/1 "2019-04-02T21:07:25Z")

</div>

Hello,

I am creating a 2D RPG game as a project in my computer engineering course entirely in C.  
I have not been trying out Python at all but I do know that you are able to write Python scripts for custom exports using Tiled.

Is it possible to write a script that exports the map as an array as such:  
{1,2,3,4,5,6},  
{1,2,3,4,5,6},  
{1,2,3,4,5,6}

If yes, then how do I do that properly in Python?

Cheers

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [April 2, 2019, 9:13pm UTC](https://discourse.mapeditor.org/t/export-map-grid-as-c-array/3861/2 "2019-04-02T21:13:38Z")

</div>

If you can get the Python plugin to work (which I think is doable on Windows, but won’t currently work on macOS and I’m also not sure how to do it on Linux), then you can indeed solve this with a Python script. If you can write Python, then I’m sure you can adjust [the example in the documentation](https://doc.mapeditor.org/en/stable/manual/python/) to write out your map in your desired format.

It may be easier to write this in JavaScript instead. For that, you need to install the “snapshot” version of Tiled and write a `startup.js` script that registers your custom map format. You can read about how to do this in the [latest documentation](https://doc.mapeditor.org/en/latest/reference/scripting/#script-registermapformat).

---

<div class="post-metadata">

**Author:** ![Alinto-1337](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/alinto-1337/32/4231_2.png) [@Alinto-1337](https://discourse.mapeditor.org/u/Alinto-1337)\
**Post date:** [August 3, 2023, 2:15pm UTC](https://discourse.mapeditor.org/t/export-map-grid-as-c-array/3861/3 "2023-08-03T14:15:00Z")

</div>

Hi I know I am 3 years late. But do you have any updates on this. In a similar situation where i want to export a tilemap as an array (every index representing the place in the spritesheet)

---

<div class="post-metadata">

**Author:** ![eishiya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/eishiya/32/2534_2.png) [@eishiya](https://discourse.mapeditor.org/u/eishiya)\
**Post date:** [August 3, 2023, 2:19pm UTC](https://discourse.mapeditor.org/t/export-map-grid-as-c-array/3861/4 "2023-08-03T14:19:04Z")

</div>

As with any custom export format, the way to go is still to write a custom script that implements a custom MapFormat. The link above is broken since the documentation was moved, the [current registerMapFormat docs are here](https://www.mapeditor.org/docs/scripting/modules/tiled.html#registerMapFormat).

You can also look into the built-in CSV export format, which exports each layer as a CSV file with the tile data. You may need to enable this format in Edit \> Preferences \> Plugins.
