Tired of manual Resources? Lex transpiles declarative data into typed GDScript (Open Source)

Hi everyone!

I’ve been working on an open-source tool called Lex to solve a common headache in Godot development: managing structured data (items, stats, quests, dialogue) without manually writing dozens of Resource scripts or dealing with fragile JSON parsing at runtime.

What is Lex? Lex is a declarative transpiler written in C++20. It takes a simple, human-readable schema and compiles it into fully typed GDScript classes that extend Resource.

Why use it for Godot?

  • Type Safety & Autocomplete: Lex generates standard GDScript. When you load your data in the editor, you get full autocompletion and type hints for all your properties.

  • Semantic Validation: Lex catches broken references at compile-time. If an item requires a prerequisite that doesn’t exist, the compiler tells you immediately, preventing null-reference crashes during gameplay.

  • Native Performance: Since it outputs GDScript, there is no overhead for parsing JSON or external formats during the game. Your data is as fast as a native script.

  • Multi-target: If you ever need to share data with a web dashboard or another engine, Lex can output the same data to JSON, Lua, or C# simultaneously.

Example: Instead of a complex dictionary in JSON, you write:

Plaintext

item Excalibur {
    name: "Excalibur"
    damage: 50
    rarity: "legendary"
}

And Lex generates the corresponding .gd file ready to be used in your project.

Try it out: You don’t need to install anything to test the syntax. I’ve built a Web Playground running via WebAssembly where you can see the GDScript output in real-time.

:globe_with_meridians: Web Playground: Lex - Game Modding Transpiler :laptop: GitHub (MIT): David-Imperium/Lex-compiler: A declarative, multi-target transpiler for game modding

I’m currently using this for the data layer of my own project, the Imperium Engine, and I’d love to hear your feedback or feature requests for the Godot backend!

1 Like