How to load and save things with Godot: a complete tutorial about serialization

They are just text, it uses the same INI style format that any other program would write. ConfigFile doesn’t save data type for built-in types (like the type for a string or an integer) but it does uses the saved data as its hint; for other types (mostly, Object inherited types) it adds the type to the data itself.

Consider the following code:

extends Node

func _ready() -> void:
	var scene = load(scene_file_path)
	var config_file = ConfigFile.new()
	config_file.set_value("Object Type", "Main Scene (Resource)", scene)
	config_file.set_value("Object Type", "Main Node (Object/Node)", self)
	config_file.set_value("Built-in Type", "Integer (int)", 1)
	config_file.set_value("Built-in Type", "Real (float)", 1.0)
	config_file.set_value("Built-in Type", "String (string)", "Hello Godot")
	config_file.save("config_file.ini")

That will generate the following INI file:

[Object Type]

"Main Scene (Resource)"=Resource("res://serialization_playground.tscn")
"Main Node (Object/Node)"=Object(Node,"_import_path":NodePath(""),"unique_name_in_owner":false,"process_mode":0,"process_priority":0,"editor_description":"","script":Resource("res://serialization_playground.gd"))


[Built-in Type]

"Integer (int)"=1
"Real (float)"=1.0
"String (string)"="Hello Godot"

Never tried to use a dictionary as if it were an array, didn’t know that. I’ll update the post

1 Like