Tiled Project File and Map Parser with Property Flattening

I noticed that, while parsers for Tiled maps exist, there doesn’t seem to be any for the project file (.tiled-project).

This became a big problem when working with custom types, since there’s not enough information from the maps alone to construct the types with all the overwritten properties.

Since parsing the project file is not a trivial task, I’ve released an npm package that helps you parse the tiled project and tiled maps together.

If your project is Javascript/Typescript-based, you can easily install the npm package and send the project file data for parsing, then retrieve your required data from the output object. A demo is shown in the README.

If your project is not Javascript/Typescript-based, it features a command line converter that reads in a project file and (optionally) the map file, and outputs an easy to use JSON object with all properties as shown in the GUI for maps and the tiled-project. These files can serve as an intermediary between the Tiled editor and your game engine to convey the necessary type and property information easily. You can clone the project from my Github repo.

Tiled also (currently) doesn’t have custom type inheritance, so this parser attempts to improve this by interpreting all nested sub-objects as being inherited, unless otherwise specified with the prefix @composite: which makes them composite subproperties with their own properties.

This behaviour can also be inverted - all nested sub-objects are composite by default (as shown in Tiled), unless otherwise specified to inherit from a parent class with the prefix @inherit: - with the custom parser options.

This is done through a recursive traversal of the nested types until all properties of an type/object/layer/tileset are completely resolved, including their overwritten values.

The inheritance behaviour was chosen because it seemed to be a more common use-case, as it would be tedious for a user to type a long property chain.

You can check out my npm package here:

The repo with the source code can be found on my GitHub:

Let me know if you encounter any issues or bugs with the parser!