This EditorScript allows you to convert CSV files into Lua tables directly inside the Defold game engine editor.
It supports both keyed tables and array tables, and is useful for importing game data like enemies, items, or maps from spreadsheets.
- ✅ Convert
.csvfiles to Lua tables - ✅ The first column of the CSV (key) can be used as the table key in the Lua output.
- ✅ Choose output format via dialog:
- Keyed table:
id = { ... } - Array table:
{ {...}, {...} }
- Keyed table:
- ✅ Ignores metadata columns using
@prefix (@note, etc.) - ✅ Supports multiline CSV fields
- ✅ Automatically strips Notion-style
(https://...)references - ✅ Supports boolean values (
true/false) correctly as Lua booleans - ✅ Supports deep nested tables by combining related columns.
- For example, CSV columns like
buffs_nameandbuffs_valueare converted into a nested Lua table:
- For example, CSV columns like
buffs_name,buffs_value
"atk_up",5buffs = { name = "atk_up", value = 5 },-
Copy
csv2lua.editor_scriptinto your project, e.g.: /editor_scripts/csv2lua.editor_script -
Project > Reload Editor Scripts
-
Right-click any .csv file in the Assets panel
-
Choose “Convert CSV to Lua Table” from the context menu.
-
A dialog will appear asking:
"Use column as keys?"
- Click "Use" to generate a keyed Lua table (e.g.
id = {...}) - Click "No" to generate an array-based table (e.g.
{ {...}, {...} })
- Click "Use" to generate a keyed Lua table (e.g.
-
A
.luafile will be generated alongside the CSV with the converted content.
Example CSV(first column "key"):
key,type,hp
slime,small,10
goblin,medium,20Output (keyed):
return {
slime = { type = "small", hp = 10 },
goblin = { type = "medium", hp = 20 },
}Output (array):
return {
slime = { "small", 10 },
goblin = { "medium", 20 },
}Example CSV(first column "not key"):
id,type,hp
slime,small,10
goblin,medium,20Output (keyed):
return {
{ id = "slime",type = "small", hp = 10 },
{ id = "goblin", type = "medium", hp = 20 },
}Output (array):
return {
{"slime", "small", 10 },
{"goblin", "medium", 20 },
}CC0 1.0 Universal