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

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".

Source: https://flockbay.com/godot/how-to-set-the-window-size-in-godot-4/ · Updated 2026-10-30

## 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)
```

## Run this fix with your agent

Flockbay is the Godot editor with an AI agent built in. Paste this into Flockbay's chat, or into Claude Code or Codex connected to Flockbay over MCP: the agent finds the cause in your project, applies the fix, runs the game headless and reads Godot's output to check it.

```
How to set the window size in Godot 4: get_window().size 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". Where this calls for a change in my Godot 4 project, make it, then run the game headless and check Godot's output for errors.
```

## 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.

Download Flockbay free: Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot. https://flockbay.com/download/

Related: [WindowDialog in Godot 4: it is Window now](/godot/windowdialog-in-godot-4/), [How to remap input actions in code in Godot 4: InputMap and keycode](/godot/how-to-remap-input-in-code-in-godot-4/), [How to get the current date and time in Godot 4: the Time singleton](/godot/how-to-get-the-current-date-and-time-in-godot-4/), [How to disable and enable a node in Godot 4: process_mode](/godot/how-to-disable-a-node-in-godot-4/), [Every verified Godot 4 answer](/godot/), [How do I connect Claude Code to Godot?](/docs/how-do-i-connect-claude-code-to-godot/)
