Format:Bethesda plugin (ESP, ESM, ESL)
| Magic | 54 45 53 34 (TES4); Morrowind: TES3 |
|---|---|
| Extensions | .esp, .esm, .esl, .esl-flagged .esp |
| Endianness | little |
| On this wiki | Facts · Code · Notes · Topics |
Plugin and master data files of Bethesda's Gamebryo and Creation Engine games (.esp, .esm, .esl; Oblivion to Starfield): a TES4 header record followed by top-level GRUP groups of records made of subrecords, with an optional zlib-compressed record body (flag 0x40000) and a form version per record.
Identification
A plugin starts with the record signature TES4 (54 45 53 34); Morrowind's TES3 is older and has a different header. Source for all details: TES5Edit/xEdit Core/wbImplementation.pas, wbInterface.pas, wbDefinitionsTES5.pas (MPL-2.0).
Record header
TES5 and Fallout 3/NV/4 style (24 bytes): signature (4 ASCII), data size u32, flags u32, FormID u32, version control u32, form version u16, version control 2 u16. Oblivion records are 20 bytes (no form version and no second version-control field). Morrowind records differ again (no FormID).
The data size excludes the header. Form versions that xEdit writes for new records: 15 Fallout 3 and New Vegas, 43 Skyrim LE, 44 Skyrim SE, 131 Fallout 4, 209 Fallout 76, 582 Starfield.
Record flag bits (the same u32 in the TES4 header record has a few game-specific meanings): 0x1 ESM, 0x20 deleted, 0x80 localized (TES4 header: strings in .STRINGS files), 0x800 initially disabled, 0x1000 ignored, 0x20000 dangerous, 0x40000 compressed (all from TwbMainRecordStructFlags in wbInterface.pas). In the TES4 header record bit 0x200 means ESL (light master, Skyrim SE and VR). Unverified: other bits (persistent, visible when distant) differ by record type and game; check wbDefinitionsTES5.pas per record.
Starfield moves the light flag: in the TES4 header record 0x100 means light (instead of 0x200), 0x200 means update, 0x400 medium and 0x800 blueprint, while the other games keep 0x200 for light (xEdit TwbMainRecordStructFlags.IsLight/IsMedium/IsBlueprint/IsUpdate, wbInterface.pas lines 20562-20593; the update flag also exists as 0x100000 for a VR ESL variant, line 20591).
Morrowind (TES3) uses a 16-byte record header: signature, data size u32, 4 bytes version control info, flags u32 (only bit 0, ESM, is named); its TES3 header record has HEDR (version float, flags u32, author 32 bytes, description 256 bytes, record count u32) and MAST/DATA pairs where DATA is a u64 master file size (xEdit wbDefinitionsTES3.pas lines 877-921; xEdit sets HEDR version 1.30 for it, line 2514).
Compression
If bit 0x40000 is set the record body is: u32 uncompressed length, then a zlib stream (Format:Zlib stream) of the remaining DataSize - 4 bytes. The header stays uncompressed. xEdit decompresses with ctZLib in TwbMainRecord.DecompressIfNeeded.
Groups
A group (GRUP) header is also 24 bytes: signature, group size u32 (size of the whole group), label u32 (four ASCII chars for top-level groups, a FormID or coordinates for cell and world children), group type i32, stamp u32, unknown u32. Group type 8 contains persistent children (xEdit sets the persistent flag on records created there). Top-level groups hold one record type each (e.g. WRLD, CELL, NPC_, REFR children inside cell groups).
Subrecords
A record body is a sequence of subrecords: signature (4 ASCII), size u16, data. If a subrecord is larger than 65535 bytes it is preceded by an XXXX subrecord holding the real size as u32 and the following subrecord has size 0 (xEdit wbImplementation.pas, handling of 'XXXX').
TES4 header record
Subrecords: HEDR (version float, record count, next object ID; xEdit constants wbHEDRVersion = 1.7 for Skyrim LE, 1.71 for Skyrim SE), CNAM author, SNAM description, repeated MAST (master file name) each followed by an 8-byte DATA, ONAM overridden forms, SCRN, INTV, INCC interior cell count. Header flag bits (wbDefinitionsTES5.pas): 0 ESM, 1 altered, 2 checked, 3 active, 4 optimized, 5 temp ID owner, 7 localized, 8 precalc data only, 9 ESL (Skyrim SE and VR only).
FormIDs
The top byte of a FormID is the load-order index of the plugin that defines it; the order of MAST entries gives the master index for records inside a plugin. Light plugins (ESL) use the load-order byte 0xFE and a 12-bit light index: FormID = 0xFE000000 | (light slot << 12) | object id (12 bits). Starfield also has medium plugins in slot 0xFD with an 8-bit index: 0xFD000000 | (medium slot << 16) | 16-bit object id. Full plugins are therefore limited to 0x00-0xFC in Starfield, 0x00-0xFD where only light plugins exist (xEdit TwbFileID, wbInterface.pas lines 22491-22626). Light plugins are supported for Skyrim SE, Enderal SE, Fallout 4 and Starfield (wbIsLightSupported, line 5358); medium only for Starfield (line 5363).
Tools
xEdit / TES5Edit (https://github.com/TES5Edit/TES5Edit, MPL-2.0) edits and conflict-checks plugins for Morrowind to Starfield.
Localized strings
When the localized flag (0x80) is set in the TES4 header record, string subrecords such as FULL and DESC hold a u32 string id instead of text. The text is in Data\Strings\<plugin>_<language>.STRINGS, .DLSTRINGS and .ILSTRINGS: see Format:Bethesda localized strings (STRINGS, DLSTRINGS, ILSTRINGS). Unverified: that every string-typed subrecord is stored as an id when the flag is set (xEdit decides per field with its localized-string types).
Code & repositories
- https://github.com/TES5Edit/TES5Edit @
9fb016884bec138ea6c7b872cec831537d464c3e· license: MPL-2.0
xEdit: plugin editor and BSArch archive tool for Bethesda games; record, group, BSA and BA2 structures in Core/
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