Used tab character for indentation instead of space as used before in the file in Godot 4
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.
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.
More on this: Tabs in Godot 4: it is TabBar now
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
onlyRun 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.
More on this: Unexpected identifier "…" in class body in Godot 4
My Godot 4 project prints this error: "Parse Error: Used tab character for indentation instead of space as used before in the file.". Find where it comes from and fix it. 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. Then run the game headless and check that Godot's output no longer shows it.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.
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.
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free