Used tab character for indentation instead of space as used before in the file in Godot 4

By Eduardo Orellana · Updated

The file was indented with spaces and then a line uses a tab, often from code pasted from a web page or another editor. The script fails to parse with Used tab character for indentation instead of space as used before in the file. Re-indent the file one way: in the Script editor, Edit, Indentation, Convert Indent to Tabs.

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

The tokenizer records the character of the first indentation it sees in a file, tab or space. Every later indented line must use the same character, and the first line that does not stops the script.

The reverse also exists: Used space character for indentation instead of tab as used before in the file. A single line that mixes both is Mixed use of tabs and spaces for indentation.

Reproduce it

A function whose first line is indented with four spaces and its second with a tab.

extends Node

func _ready() -> void:
    print("spaces")
	print("tab")

What Godot 4.7.2 prints

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

SCRIPT ERROR: Parse Error: Used tab character for indentation instead of space as used before in the file.
   at: GDScript::reload (res://answers/used-tab-character-for-indentation-instead-of-space/repro.gd:5)
ERROR: Failed to load script "res://answers/used-tab-character-for-indentation-instead-of-space/repro.gd" with error "Parse error".
   at: load (modules/gdscript/gdscript_resource_format.cpp:46)

Fix it

The same function indented with tabs only.

extends Node

func _ready() -> void:
	print("tabs")
	print("only")

What the fixed script prints

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

tabs
only

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_tokenizer.cpp line 1240, the message](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_tokenizer.cpp#L1240).

Questions

Does Godot prefer tabs or spaces?
Godot's editor and its style guide use tabs. Spaces work if the whole file uses them.
How do I see which lines use spaces?
Turn on Editor Settings, Text Editor, Appearance, Whitespace, Draw Tabs and Draw Spaces.