Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.


The most important data type in Godot.


In computer programming, a Variant class is a class that is designed to store a variety of other types. Dynamic programming languages like PHP, Lua, JavaScript and GDScript like to use them to store variables' data on the backend. With these Variants, properties are able to change value types freely.

var foo = 2 # foo is dynamically an integer
foo = "Now foo is a string!"
foo = # foo is an Object
var bar: int = 2 # bar is a statically typed integer.
# bar = "Uh oh! I can't make static variables become a different type!"

Godot tracks all scripting API variables within Variants. Without even realizing it, you use Variants all the time. When a particular language enforces its own rules for keeping data typed, then that language is applying its own custom logic over the base Variant scripting API.

  • GDScript automatically wrap values in them. It keeps all data in plain Variants by default and then optionally enforces custom static typing rules on variable types.

  • C# is statically typed, but uses its own implementation of the Variant type in place of Godot's Variant class when it needs to represent a dynamic value. A Variant can be assigned any compatible type implicitly but converting requires an explicit cast.

The global @GlobalScope.typeof function returns the enumerated value of the Variant type stored in the current variable (see Variant.Type).