TExcelTAD
Home › Godot 4 with GDScript › Exporting: Templates, Android & Web

Exporting: Templates, Android & Web

Exporting turns your project into something players can run without the editor: an .exe, a Linux binary, an .apk/.aab, or a folder of web files. Godot does this by combining an export template (a prebuilt, optimised engine without the editor) with a .pck file that holds your scenes, scripts and imported assets. Export early: the first export of a project usually finds missing files, editor-only code and platform surprises, and it's better to find them in week one than the night before a jam deadline.

1. Install the export templates

Templates must match your editor version exactly (a 4.7.2 editor needs 4.7.2 templates).

  1. Open Editor > Manage Export Templates.
  2. Click Download and Install. Godot fetches the templates for your exact version from a mirror (about 1 GB unpacked, since they cover every platform).
  3. Offline machines can use Install from File with the .tpz archive from godotengine.org's download page.

The .NET build has its own templates; they are not interchangeable with the standard ones.

2. Create presets

  1. Open Project > Export....
  2. Click Add... and choose a platform: Windows Desktop, Linux, macOS, Android, iOS, Web.
  3. Set the Export Path (for example build/windows/MyGame.exe) and review the options. Warnings in red at the bottom tell you what's missing (templates, an Android SDK path, a keystore).
  4. Click Export Project (choose Export With Debug off for a release) or Export PCK/ZIP to export only the game data.

Presets are saved in export_presets.cfg next to project.godot. Commit it, so your teammates and your CI use the same settings. Passwords for signing are kept in .godot/export_credentials.cfg, which is not committed. A trimmed excerpt:

ini
[preset.0]

name="Web"
platform="Web"
runnable=true
export_filter="all_resources"
include_filter="data/*.json"
exclude_filter="test/*"
export_path="build/web/index.html"

[preset.0.options]

variant/thread_support=false
progressive_web_app/enabled=false

include_filter matters: Godot exports resources it knows about. Plain files that aren't imported (a levels.json you read with FileAccess, a .txt dialogue file) must be listed there, or they are missing in the export while working in the editor. This is the most common "works in the editor, broken in the build" bug.

3. Feature tags: code that knows where it runs

Every build has feature tags: the platform (windows, linux, android, web), the class of device (pc, mobile), editor or template, debug or release, plus any custom tags you add to a preset (demo, steam). Query them with OS.has_feature(). Here is what the editor binary used to verify this course reports on Linux:

gdscript · try it yourself
extends SceneTree

func _init():
	print("OS: ", OS.get_name())
	for tag in ["editor", "template", "debug", "release", "pc", "mobile", "web", "linux", "demo"]:
		print(tag.rpad(9), OS.has_feature(tag))
	quit()
OS: Linux
editor   true
template false
debug    true
release  false
pc       true
mobile   false
web      false
linux    true
demo     false

Typical uses: hide the Quit button on the web (if OS.has_feature("web"): quit_button.hide()), show touch controls on mobile, enable cheats only with debug, cut levels with a custom demo tag. Project settings can also be overridden per tag: in Project Settings, click the gear next to a setting and add an override such as display/window/size/mode.mobile.

4. Desktop

  • Windows, Linux: the export is an executable plus a .pck next to it. Tick Embed PCK in the preset to get a single file.
  • macOS: exports an .app (in a .zip or .dmg). Apple requires code signing and notarization for apps downloaded from the internet; without them players see a security warning. Signing can be done from the preset with your Apple developer credentials, or afterwards with Apple's tools.
  • Set the icon (Project Settings > Application > Config > Icon, plus the per-platform icon options in the preset) and the version (application/config/version).

5. Android

From the official setup guide (check the current page; required versions change with Android itself):

  1. Install OpenJDK 17 (the version the docs recommend) and the Android SDK (through Android Studio or the sdkmanager command-line tool).
  2. In Editor > Editor Settings, under Export > Android, set Java SDK Path and Android SDK Path.
  3. Add an Android preset. Godot creates a debug keystore for development, so debug builds can be installed right away.
  4. Plug in a phone with USB debugging on: a one-click deploy button (the Android icon) appears at the top right of the editor; it exports, installs and runs the game on the device with the debugger attached.
  5. For release, create your own keystore and enter it in the preset's Keystore > Release fields:
bash
keytool -v -genkey -keystore mygame.keystore -alias mygame -keyalg RSA -validity 10000
  1. Google Play needs an Android App Bundle (.aab). Enable Gradle Build > Use Gradle Build in the preset (Godot installs an Android build template into the project with Project > Install Android Build Template) and set the export format to AAB.

Back up the release keystore. If you lose it, you can't publish updates to the same app on the store.

6. Web

Web exports run in any modern browser through WebAssembly and WebGL 2. Rules:

  • Web exports use the Compatibility renderer. Choose it when you create the project if the web is your main target, so you see the same result while you work.
  • GDScript only: C# projects can't be exported to the web in Godot 4 (see C# in Godot).
  • Since Godot 4.3 the default export is single-threaded. It runs on hosts such as itch.io without special server headers.
  • If you turn on Thread Support in the preset (for heavier games or low-latency audio), the page needs SharedArrayBuffer, which browsers only allow on a cross-origin isolated page. Your server must send:
text
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

The Progressive Web App option can inject these with a service worker when you can't change the server headers.

  • The export is a folder: index.html, a .js loader, the engine .wasm (serve it as application/wasm), the game .pck, and icons. Zip the folder for itch.io and tick its "This file will be played in the browser" option.
  • Opening index.html from disk doesn't work. Test locally with Run in Browser (the HTML5 icon at the top right of the editor), which starts a local web server.
  • Browsers block audio until the first click or key press, and the first load downloads the whole engine (gzip or Brotli on the server helps a lot).

7. Exporting from the command line

CI pipelines and build scripts export without opening the editor. Use the editor binary (not a template), quote preset names with spaces, and make sure the target folder exists:

bash
godot --headless --path . --export-release "Windows Desktop" build/windows/MyGame.exe
godot --headless --path . --export-release "Web" build/web/index.html
godot --headless --path . --export-debug "Android" build/android/mygame-debug.apk
godot --headless --path . --export-pack "Linux" build/patch.pck

--headless is required on servers without a GPU. The export commands import the project's assets first, so a fresh checkout works. Community GitHub Actions (search for "godot export action") wrap these commands with the right templates.

Release checklist

Check Why
Templates match the editor version mismatched templates refuse to export
Non-resource files are in the include filter data files missing from the build
No res:// writes; saves go to user:// res:// is read-only in exports (see Saving)
Debug-only code is behind OS.is_debug_build() cheats and debug draw stay out of releases
Tested the exported build, not just the editor file-name case, missing files and shader caches only show up there
Version number and icon set stores and players see them
Android release keystore backed up lost keystore = no updates

Test yourself

Your game reads res://data/levels.json with FileAccess. It works in the editor but the file is missing in the export. What's the usual fix?

  1. Rename it to .tres
  2. Add data/*.json to the preset's include filter (non-resource files)
  3. Use the .NET build
  4. Export with debug

A web export with Thread Support enabled shows a blank page on your host. What is most likely missing?

  1. The Android SDK
  2. The COOP/COEP headers that make the page cross-origin isolated for SharedArrayBuffer
  3. A C# runtime
  4. An export template for Linux

How do you hide the Quit button only in web builds?

  1. if OS.get_name() == "HTML"
  2. if OS.has_feature("web"): quit_button.hide()
  3. Make two separate projects
  4. Web builds can't hide buttons