File paths in Godot projects¶
This page explains how file paths work inside Godot projects. You will learn howto access paths in your projects using theres:// anduser:// notationsand where Godot stores user files on your hard-drive.
Path separators¶
To make supporting multiple platforms easier, Godot only accepts UNIX-style pathseparators (/). These work on all platforms,including Windows.
Instead of writing paths likeC:\Projects, in Godot, you should writeC:/Projects.
Accessing files in the project folder¶
Godot considers that a project exists in any folder that contains aproject.godot text file, even if the file is empty. The folder that containsthis file is your project's root folder.
You can access any file relative to it by writing paths starting withres://, which stands for resources. For example, you can access an imagefilecharacter.png located in the project's root folder in code with thefollowing path:res://character.png.
Accessing persistent user data¶
To store persistent data files, like the player's save or settings, you want touseuser:// instead ofres:// as your path's prefix. This is becausewhen the game is running, the project's file system will likely be read-only.
Theuser:// prefix points to a different directory on the user's device.Unlikeres://, the directory pointed at byuser:// isguaranteed to bewritable to, even in an exported project.
On desktop platforms, the actual directory paths foruser:// are:
Type | Location |
|---|---|
User data |
|
User data(when |
|
[project_name] is based on the application name defined in the Project Settings, butyou can override it on a per-platform basis usingfeature tags.
On mobile platforms, this path is unique to the project and is not accessibleby other applications for security reasons.
On HTML5 exports,user:// will refer to a virtual filesystem stored on thedevice via IndexedDB. (Interaction with the main filesystem can still be performedthrough theJavaScript singleton.)
Editor data paths¶
The editor uses different paths for user data, user settings, and cache,depending on the platform. By default, these paths are:
Type | Location |
|---|---|
User data |
|
User data(when |
|
User settings |
|
Cache |
|
User data contains export templates and project-specific data.
User settings contains editor settings, text editor themes, scripttemplates, etc.
Cache contains temporary data. It can safely be removed when Godot isclosed.
Godot complies with theXDG Base Directory Specificationon all platforms. You can override environment variables following thespecification to change the editor and project data paths.
Note
If you useGodot packaged as a Flatpak, theeditor data paths will be located in subfolders in~/.var/app/org.godotengine.Godot/.
Self-contained mode¶
If you create a file called._sc_ or_sc_ in the same directory as theeditor binary, Godot will enableself-contained mode. This mode makes Godotwrite all user data to a directory namededitor_data/ in the same directoryas the editor binary. You can use it to create a portable installation of theeditor.
TheSteam release of Godot usesself-contained mode by default.
Note
Self-contained mode is not supported in exported projects yet.To read and write files relative to the executable path, useOS.get_executable_path().Note that writing files in the executable path only works if the executableis placed in a writable location (i.e.not Program Files or anotherdirectory that is read-only for regular users).