# Start every tileset ID from 0

**URL:** <https://discourse.mapeditor.org/t/start-every-tileset-id-from-0/2944>\
**Category:** Questions\
**Created:** [January 19, 2018, 4:13am UTC](https://discourse.mapeditor.org/t/start-every-tileset-id-from-0/2944 "2018-01-19T04:13:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![naknode](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/naknode/32/1593_2.png) [@naknode](https://discourse.mapeditor.org/u/naknode)\
**Post date:** [January 19, 2018, 4:13am UTC](https://discourse.mapeditor.org/t/start-every-tileset-id-from-0/2944/1 "2018-01-19T04:13:45Z")

</div>

So I have two tileset:

- background
- foreground

The background has 252 tiles (32x32) and foreground has like 100. On the Tiled application, the Properties tab shows the very first ID of the _foreground_ as 0. OK, Cool. The background Tile ID is zero as well (as it should be).

But when I export the Map as JSON, the Tile ID on the Foreground changes. Instead of Zero it is now 253.

How do I make it so every tileset ID starts from zero instead of the last ID? This is so odd. I’m pretty new to Tiled and I don’t want to have to keep doing minus (last ID) to calculate correctly the ID.

Any help is appreciated.

---

<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:** [January 19, 2018, 8:39am UTC](https://discourse.mapeditor.org/t/start-every-tileset-id-from-0/2944/2 "2018-01-19T08:39:35Z")

</div>

> [@naknode](#):
>
> How do I make it so every tileset ID starts from zero instead of the last ID? This is so odd. I’m pretty new to Tiled and I don’t want to have to keep doing minus (last ID) to calculate correctly the ID.

You can’t do this, because you wouldn’t be able to determine from which tileset that particular tile is (not without additional knowledge at least: only you know that you have only two layers that only use a specific tileset for each).

The way to get from 253 to 0 is to subtract the “firstgid” associated with your second tileset. In the general case, this system allows a tile layer to use any number of tilesets. You can read more about this in [the documentation](http://doc.mapeditor.org/en/latest/reference/tmx-map-format/#data) (the JSON format works the same way).

---

<div class="post-metadata">

**Author:** ![naknode](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/naknode/32/1593_2.png) [@naknode](https://discourse.mapeditor.org/u/naknode)\
**Post date:** [January 19, 2018, 8:48pm UTC](https://discourse.mapeditor.org/t/start-every-tileset-id-from-0/2944/3 "2018-01-19T20:48:49Z")

</div>

Hi @bjorn. Thank you for responding. What if my map had two tilesets and two layers. One tileset belonging to each layer.

What about then?

---

<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:** [January 21, 2018, 2:17pm UTC](https://discourse.mapeditor.org/t/start-every-tileset-id-from-0/2944/4 "2018-01-21T14:17:02Z")

</div>

It doesn’t matter, Tiled supports multiple tilesets per layer so it can’t change its output format to rely on there being only a single tileset per layer. It could be introduced as an option, but Tiled currently has no such option.

But, you can always implement your own map format, and teach Tiled how to read/write it by implementing either a C++ or Python Tiled plugin. Then you can simplify it as much as you like.
