Skyrim Mod:File Format Conventions

Mod / Skyrim: Skyrim Mod: File Formats

Listed here are conventions used in describing Skyrim file formats. Many of these conventions are standard c-type conventions, others (e.g., iref) are specific to this subject.


Text Usage
num Count of something. E.g. number of records.
size Size in bytes of some data object.
?Huh? Question or speculation.
[indent] Substructure.

Data TypesEdit

Type Size Description
null/empty 0 Field with no data, usually used as a marker or flag.
char 1 8-bit character.
wchar 2 16-bit character.
int8 1 8-bit value, signed.
uint8 1 8-bit value, unsigned.
int16 2 16-bit value, signed.
uint16 2 16-bit value, unsigned.
int32 4 32-bit value, signed.
uint32 4 32-bit value, unsigned.
int64 8 64-bit value, signed.
uint64 8 64-bit value, unsigned.
float32 4 32-bit value, floating-point.
float64 8 64-bit value, floating-point.
The type names listed in this block should be considered deprecated and you should instead use the type names in the previous block.
byte 1 Byte, signed.
ubyte 1 Byte, unsigned.
  • Also used for unknown and/or complex data structures.
char 1 Character, signed.
  • Used for text.
short 2 Short integer, signed.
ushort 2 Short integer, unsigned.
long 4 Long integer, signed.
ulong 4 Long integer, unsigned.
  • Also used to represent a set of binary flags.
float 4 Floating point number
vsval 1+?? Variable-sized value, the type of vsval depends on the first byte: the lowest 2 bits represents the type of the vsval:
  • 0 = uint8
  • 1 = uint16
  • 2 = uint32

The value is in the rest of the bits of the value type.

  • value <= 0x40 becomes uint8, (byte1 >> 2)
  • value <= 0x4000 becomes uint16, (byte1 | (byte2 << 8)) >> 2
  • value <= 0x40000000 becomes uint32, (byte1 | (byte2 << 8) | (byte3 << 16) >> 2

Note: bytes are stored in little-endian format. So, the least significant bytes will come first. (Bits are still most significant first)

Example process for reading a uint16 vsval:

  1. Read one byte. We will use 0xE1 for our example (or 11100001 in binary).
  2. The rightmost bits are least significant, so that is where our vsval type is stated. In this case, the rightmost bits are 01, so the type of this vsval is uint16 (so, we will have two bytes total).
  3. Read the next byte. We will use 0x13 for our example (or 00010011 in binary). Shift this byte to the left 8 bits and logical or it with the first byte such that uint16 = ((byte2 << 8) | byte1). So now we have 0x13E1 (or 00010011 11100001 in binary).
  4. Finally, shift the resulting uint16 to the right 2 bits to get the resulting value of 0x04F8 (or 00000100 11111000 in binary).

Note: When reading a uint32 value, follow the same procedure except shift the third byte to the left 16 bits and logical or it with the uint16 before shifting the resulting uint32 to the right 2 bits.

formid 4 A ulong used to identify a data object. May refer to a data object from a mod or new object created in-game.
iref 4 A ulong. Use as an index into the FormIDs Array to get the formId.
hash 8 A hash of a string. See BSA File Format: Hash Calculation.
filetime 8 FILETIME structure.
systemtime 16 SYSTEMTIME structure.
rgb 4 4 unsigned bytes, containing red, green, blue, ?alpha? values
type[num] num*sizeof(type) Array of num types.
stringId 4 See lstring.
4 'Localized string', a ulong that is used as an index to look up string data information in one of the string tables. Note that the record header for the TES4 record indicates if the file is localized or not. If not, all lstrings are zstrings.
bstring 1+?? A string prefixed with a byte length. NOT zero terminated.
  • This and other string types use Windows-1252 encoding.
  • However, not all fields allow the full range -- e.g., editor ids are limited to [a-zA-Z0-9].
bzstring 1+?? A string prefixed with a byte length and terminated with a zero (\x00).
wstring 2+?? A string prefixed with a uint16 length. NOT zero terminated.
  • This and other string types use Windows-1252 encoding.
  • However, not all fields allow the full range -- e.g., editor ids are limited to [a-zA-Z0-9].
wzstring 2+?? A string prefixed with a uint16 length and terminated with a zero (\x00).
zstring  ??+1 Zero terminated string.
  • Size is size of string text + 1 for string terminator.
string  ?? String which is not terminated
  • Size is the exact number of characters in the string.
struct  ?? Collection of other data types.
  • Used to group items that logically belong together. E.g., pc cell data.
  • Size is sum of item sizes.
list[len]  ?? List of items of variable length, and possibly different types.
  • Size is sum of item sizes.

C (Count)Edit

This is used for plugin fields.

Count Usage
? Unknown
+ Required
- Optional
* Repeating
  • Repeat count may be zero.
  • If fields are repeated in a form (e.g., MAST and DATA in TES4), then the following subrecords are indented under the leading subrecord.

V (Version)Edit

The version of the form that contains that field. See Records format.