File I/O & JSON Parsing
Read and write game data using FileAccess, JSON parsing, and configuration files.
Scripting
No shortcutIntermediate6 min readQuick Reference
File I/O & JSON Parsing
Godot EngineKeyboard Shortcut
N/A
Where to Find
Select any node → Click Attach Script button, or Script Editor panel
Best Used For
- ▸Write game logic with variables and functions
- ▸Connect nodes via signals for decoupled systems
- ▸Expose Inspector properties for designer tweaking
Intermediate⏱ 30–60 minutes to master
Key Settings
Open:Write JSON:Read JSON:Paths:
File I/O in Godot uses FileAccess to read and write files. JSON is the primary format for structured data interchange.
Where to Find It
Use FileAccess class in GDScript. JSON functions are built into the engine.
How to Use
- Open:
var file = FileAccess.open("user://save.json", FileAccess.WRITE). - Write JSON:
file.store_string(JSON.stringify(data)). - Read JSON:
var data = JSON.parse_string(file.get_as_text()). - Paths: Use
user://for persistent data,res://for read-only game files.
Pro Tips
- Always check
file_open()returns a valid file handle. - Use
ResourceSaverandResourceLoaderfor complex data. - Store configuration in
.cfgfiles using ConfigFile class.