Format:VPK (Valve package)
| Versions | 1, 2 (Respawn uses a customised version 0x00030002) |
|---|---|
| Magic | 34 12 AA 55 |
| Extensions | .vpk |
| Endianness | little |
| On this wiki | Facts · Code · Notes · Topics |
Archive format of Valve's Source and Source 2 games (_dir.vpk plus numbered _000.vpk data archives): a 12- or 28-byte little-endian header (magic 0x55AA1234, version 1 or 2), a directory tree of extension, directory and file names with 18-byte entries, and file data in separate archive files or after the tree.
Config and manifest files inside are usually Format:KeyValues1 (VDF, ACF) text.
Layout
All integers are little-endian. The file starts with a header:
| Offset | Size | Field |
|---|---|---|
| 0 | 4 | magic 0x55AA1234 (bytes 34 12 AA 55) |
| 4 | 4 | version (1 or 2) |
| 8 | 4 | TreeSize: length of the directory tree |
| 12 | 4 | FileDataSectionSize (version 2 only) |
| 16 | 4 | ArchiveMD5SectionSize (v2) |
| 20 | 4 | OtherMD5SectionSize (v2, 48 expected) |
| 24 | 4 | SignatureSectionSize (v2) |
The header is 12 bytes in version 1 and 28 bytes in version 2. The directory tree follows at HeaderSize and is TreeSize bytes long.
Directory tree
Three nested lists of NUL-terminated strings, each list ended by an empty string: file extension, then directory path, then file name (without extension). After every file name comes an 18-byte entry: CRC32 (4), PreloadBytes (2), ArchiveIndex (2), EntryOffset (4), EntryLength (4), terminator 0xFFFF (2). PreloadBytes bytes of file data follow the entry inside the tree itself; the rest of the file (EntryLength bytes) is read at EntryOffset from the archive named by ArchiveIndex. A single space is used by tools as a placeholder for an empty extension, directory or name (check the reader you use).
Archives
A multi-file package consists of name_dir.vpk (header and tree) and name_000.vpk, name_001.vpk ... (data, index formatted with three digits). ArchiveIndex 0x7FFF means the data is embedded in the _dir.vpk file itself, directly after the tree (offset relative to HeaderSize + TreeSize).
Version 2 trailer
After the file data come the archive MD5 section (entries of archive index, hash type, offset, length and a 16-byte MD5), an 'other MD5' section of 48 bytes (MD5 of the tree, of the archive MD5 section and of the whole file up to there) and an optional signature section (public key and signature, RSA, so a signed package can be verified).
Details from SteamDatabase/ValvePak (Package.Read.cs, EHashType.cs, ESignatureType.cs, MIT):
- Archive MD5 section entries are 28 bytes: ArchiveIndex u16, HashType u16 (0 = MD5, 1 = Blake3 in the enum), Offset u32, Length u32, 16 bytes of checksum. The section size must be a multiple of 28. These are per-chunk hashes of the archive files (cache line hashes). A legacy quirk: an entry with ArchiveIndex 0 and HashType 0x8000 is read as the embedded archive 0x7FFF with MD5.
- Other MD5 section (expected size 48): MD5 of the directory tree (16), MD5 of the archive MD5 entries (16), MD5 of the whole file up to this point (16).
- Signature section: classic form is public key size i32, public key bytes, signature size i32, signature bytes (signature type 'full file'). A newer 20-byte form starts with the VPK magic 0x55AA1234 in the key-size position, followed by signature type i32 (0 = full file, 1 = only file checksum), public key size, signature size and a reserved i32, then the key and signature.
- Directory tree entry reading checks the 0xFFFF terminator; tree strings are UTF-8. The CRC32 of an entry covers preload bytes plus the bytes read from the archive.
- Source 2 packages hold compiled resources, see Format:Source 2 compiled resource (_c).
Variants
Respawn's Titanfall and Apex Legends use a customised package with version 0x00030002 that ValvePak refuses to read.
Code & repositories
See linked repositories.
- https://github.com/SteamDatabase/ValvePak @
32c9858f2305bf4d12320374753b951ddeb6042d· license: MIT
C# reader and writer of VPK v1/v2 packages, with MD5 and signature verification
Tested on: source read, not run: read source only · checked 2026-10-18; last activity 2026-10-17