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://
notations,and where Godot stores project and editor files on your and your users' systems.
Path separators
To make supporting multiple platforms easier, Godot usesUNIX-style pathseparators (forward slash/
). These work on all platforms,includingWindows.
Instead of writing paths likeC:\Projects\Game
, in Godot, you should writeC:/Projects/Game
.
Windows-style path separators (backward slash\
) are also supported in somepath-related methods, but they need to be doubled (\\
), as\
is normallyused as an escape for characters with a special meaning.
This makes it possible to work with paths returned by other Windowsapplications. We still recommend using only forward slashes in your own code toguarantee that everything will work as intended.
Tip
The String class offers over a dozen methods to work with strings that represent file paths:
Accessing files in the project folder (res://
)
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 (user://
)
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://
is createdautomatically andguaranteed to be writable to, even in an exported project.
The location of theuser://
folder depends on what is configured in theProject Settings:
By default, the
user://
folder is created within Godot'seditor data path in theapp_userdata/[project_name]
folder. This is the default so that prototypesand test projects stay self-contained within Godot's data folder.Ifapplication/config/use_custom_user_diris enabled in the Project Settings, the
user://
folder is creatednextto Godot's editor data path, i.e. in the standard location for applicationsdata.By default, the folder name will be inferred from the project name, but itcan be further customized withapplication/config/custom_user_dir_name.This path can contain path separators, so you can use it e.g. to groupprojects of a given studio with a
StudioName/GameName
structure.
On desktop platforms, the actual directory paths foruser://
are:
Type | Location |
---|---|
Default | Windows: %APPDATA%\Godot\app_userdata\[project_name] macOS: ~/Library/ApplicationSupport/Godot/app_userdata/[project_name] Linux: ~/.local/share/godot/app_userdata/[project_name] |
Custom dir | Windows: %APPDATA%\[project_name] macOS: ~/Library/ApplicationSupport/[project_name] Linux: ~/.local/share/[project_name] |
Custom dir and name | Windows: %APPDATA%\[custom_user_dir_name] macOS: ~/Library/ApplicationSupport/[custom_user_dir_name] Linux: ~/.local/share/[custom_user_dir_name] |
[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 theJavaScriptBridge singleton.)
Converting paths to absolute paths or "local" paths
You can useProjectSettings.globalize_path()to convert a "local" path likeres://path/to/file.txt
to an absolute OS path.For example,ProjectSettings.globalize_path()can be used to open "local" paths in the OS file managerusingOS.shell_open() since it only acceptsnative OS paths.
To convert an absolute OS path to a "local" path starting withres://
oruser://
, useProjectSettings.localize_path().This only works for absolute paths that point to files or folders in yourproject's root oruser://
folders.
Editor data paths
The editor uses different paths for editor data, editor settings, and cache,depending on the platform. By default, these paths are:
Type | Location |
---|---|
Editor data | Windows: %APPDATA%\Godot\ macOS: ~/Library/ApplicationSupport/Godot/ Linux: ~/.local/share/godot/ |
Editor settings | Windows: %APPDATA%\Godot\ macOS: ~/Library/ApplicationSupport/Godot/ Linux: ~/.config/godot/ |
Cache | Windows: %TEMP%\Godot\ macOS: ~/Library/Caches/Godot/ Linux: ~/.cache/godot/ |
Editor data contains export templates and project-specific data.
Editor settings contains the main editor settings configuration file aswell as various other user-specific customizations (editor layouts, featureprofiles, script templates, etc.).
Cache contains data generated by the editor, or stored temporarily.It can safely be removed when Godot is closed.
Godot complies with theXDG Base Directory Specificationon Linux/*BSD. You can override theXDG_DATA_HOME
,XDG_CONFIG_HOME
andXDG_CACHE_HOME
environment variables to change the editor and project datapaths.
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 (or inMacOS/Contents/ for a macOS editor .app bundle), Godotwill enableself-contained mode.This mode makes Godot write all editor data, settings, and cache to a directorynamededitor_data/
in the same directory as the editor binary.You can use it to create a portable installation of the editor.
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).