How to set the window size in Godot 4: get_window().size

By Eduardo Orellana · Updated

Set get_window().size = Vector2i(1280, 720) in code, or set the default in Project Settings, Display, Window, Size. Godot 3's OS.window_size is gone: it fails to parse with Cannot find member "window_size" in base "OS".

AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.

Intel or AMD Chromebook, with Linux turned on.

Download for macOSDownload for Windows

What Godot is checking

Godot 4 moved window control off OS. Each window is a Window node, the game's main one is get_window() from any node, and its size, position and mode are its properties. DisplayServer offers the same calls by window id.

The size is a Vector2i, in pixels. This page's run is headless, with no real window, and shows the Window node taking the size.

Reproduce it

A Godot 3 window size, in a Godot 4 project.

extends Node

func _ready():
	OS.window_size = Vector2(1280, 720)

What Godot 4.7.2 prints

Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

SCRIPT ERROR: Parse Error: Cannot find member "window_size" in base "OS".
   at: GDScript::reload (res://answers/how-to-set-the-window-size-in-godot-4/repro.gd:4)
ERROR: Failed to load script "res://answers/how-to-set-the-window-size-in-godot-4/repro.gd" with error "Parse error".
   at: load (modules/gdscript/gdscript_resource_format.cpp:46)

Fix it

Set the main window's size and read it back.

extends Node

func _ready() -> void:
	get_window().size = Vector2i(1280, 720)
	print(get_window().size)

What the fixed script prints

Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

(1280, 720)

Verified on Godot 4.7.2

Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 18 October 2026, and the output above is what Godot printed, unedited.

Where the check lives in Godot's source: [gdscript_analyzer.cpp line 4122, the message](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_analyzer.cpp#L4122), [Window.size in the class reference](https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Window.xml).

Questions

How do I make the window fullscreen?
get_window().mode = Window.MODE_FULLSCREEN, or DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN).
How do I keep the game the same size on any window?
Set Project Settings, Display, Window, Stretch, Mode to canvas_items or viewport, and pick an aspect.