Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Godot variant binary encoding

From ReverseEngineering.wiki
Format
Vendor Godot Engine
Endianness little-endian
On this wiki Facts · Code · Notes · Topics

The binary Variant encoding of the Godot engine (core/io/marshalls.cpp), used by FileAccess.store_var / get_var, bytes_to_var and the multiplayer API: a 32-bit header whose low byte is the Variant type, then little-endian data padded to 4 bytes.

Overview

Godot games often save with FileAccess.store_var(value) (or var_to_bytes), which writes the Variant binary encoding with no file magic, or with ConfigFile / JSON text, or ResourceSaver (.tres/.res). The binary encoding is in core/io/marshalls.cpp (MIT). Every value begins with a 32-bit little-endian header: byte 0 is the Variant::Type, byte 1 unused, bytes 2 and 3 carry flags (for INT and FLOAT bit 16 means 64-bit data; for OBJECT bit 16 means object-as-id; ARRAY and DICTIONARY use bits 16-17 for typed containers).

Variant types (Variant::Type order in core/variant/variant.h)

0 NIL, 1 BOOL, 2 INT, 3 FLOAT, 4 STRING, 5 VECTOR2, 6 VECTOR2I, 7 RECT2, 8 RECT2I, 9 VECTOR3, 10 VECTOR3I, 11 TRANSFORM2D, 12 VECTOR4, 13 VECTOR4I, 14 PLANE, 15 QUATERNION, 16 AABB, 17 BASIS, 18 TRANSFORM3D, 19 PROJECTION, 20 COLOR, 21 STRING_NAME, 22 NODE_PATH, 23 RID, 24 OBJECT, 25 CALLABLE, 26 SIGNAL, 27 DICTIONARY, 28 ARRAY, 29 PACKED_BYTE_ARRAY, 30 PACKED_INT32_ARRAY, 31 PACKED_INT64_ARRAY, 32 PACKED_FLOAT32_ARRAY, 33 PACKED_FLOAT64_ARRAY, 34 PACKED_STRING_ARRAY, 35 PACKED_VECTOR2_ARRAY, 36 PACKED_VECTOR3_ARRAY, 37 PACKED_COLOR_ARRAY, 38 PACKED_VECTOR4_ARRAY. Unverified: the numbering differs in older engine versions (Godot 3); read the enum of the version the game uses.

Data

  • NIL: nothing. BOOL: u32 0 or 1. INT: 4 bytes, or 8 with the 64-bit flag. FLOAT: f32, or f64 with the flag.
  • STRING and STRING_NAME: u32 byte length, UTF-8 bytes, zero padding so the total is a multiple of 4 (_encode_string).
  • Checked (godot core/io/marshalls.cpp @ 81ab961f91, decode_variant): Vector2 is two reals and Transform2D six reals (column by column), read as f64 when the 64-bit data flag is set and as f32 otherwise; Color is always four f32 (r, g, b, a), no 64-bit variant.
  • Checked: DICTIONARY (and ARRAY) first carry optional typed-container descriptors selected by header bits, then a u32 whose low 31 bits are the element count (the top bit is a "shared" flag the decoder ignores), then the elements as full Variants (key then value for a dictionary).
  • Checked: encode_variant takes p_full_objects; when false an OBJECT is stored as an object id only (EncodedObjectAsID), when true it writes the class name string and the property list (a null object is a u32 0). The decoder likewise takes p_allow_objects.

Text save formats

ConfigFile writes INI-like text: [section], a blank line, then key=value lines with values in Godot's text Variant syntax (config_file.cpp). FileAccess.open_encrypted / open_encrypted_with_pass files (the usual way to store an encrypted save) are the format of core/io/file_access_encrypted.cpp: magic GDEC (u32 0x43454447, bytes 47 44 45 43), 16-byte MD5 of the plaintext, u64 plaintext length, 16-byte IV, then the data zero-padded to 16 bytes and encrypted with AES-256 in CFB mode; a password is turned into the key as the 32 ASCII hex characters of its MD5. See #Encrypted files.

See also Library:Godot Engine, Format:Godot PCK, Technique:Reverse engineering game save files.

Encrypted files

Read from godot core/io/file_access_encrypted.cpp at 81ab961f91 (open_and_parse lines 35-96, open_password 98-107, _close 110-143) and file_access_encrypted.h line 36:

Offset Size Field
0 4 magic GDEC (ENCRYPTED_HEADER_MAGIC 0x43454447), absent when the file was opened without magic
4 16 MD5 of the plaintext
20 8 plaintext length (u64)
28 16 IV
44 n ciphertext, length rounded up to a multiple of 16, AES-256 CFB (key must be 32 bytes)

A wrong key is detected by the MD5 check ("The MD5 sum of the decrypted file does not match the expected value"). The plaintext is usually a store_var / ConfigFile stream as above. The key of a game is embedded in its executable or passed at runtime (Unverified for any given game: search the binary for 32 byte strings near the open_encrypted call).

Code & repositories

  • https://github.com/godotengine/godot @ 81ab961f91066a63bcbf3ec340962bb1a1ada558 · license: MIT
    core/io/marshalls.cpp encodes and decodes Variants (header, flags, padding); core/variant/variant.h has the type enum; core/io/config_file.cpp writes ConfigFile text.
    Tested on: source read, not run: source read, not run · checked 2026-10-18; last activity 2026-10-18; Note: the latest release ships binaries; the wiki links only the source, never the binaries