File Formats
Everything a Source 2 game loads is stored in a few layered formats. This page summarizes the chain; the rest of the section documents each layer in detail.
The storage chain
A game's content ships in VPK archives: pak01_dir.vpk plus its numbered chunk files in the game directory. Every compiled map is a VPK of its own, and workshop items are published as VPKs too.
Inside those archives, every asset is a compiled resource: a file whose extension ends in _c, such as .vmat_c, .vmdl_c or .vpcf_c. Whatever the type, the file is the same container, a small header followed by named blocks, and the types only differ in which blocks they carry. The Asset Types table lists every type and what compiles it.
The payload of a modern compiled resource is binary KV3. The oldest Source 2 games predate binary KV3 and pack their payloads as C structs instead, described by an introspection block in the same container.
A _c file is never authored directly: assets are written as plain source files and compiled. How that pipeline works, the content\ and game\ split, and how compiled files are decompiled back are covered in Basics: content/ and game/ and Decompiling assets.
Which format is used where
Four serialization formats cover nearly everything:
| Format | Used for |
|---|---|
| KV3, text | most authored source assets: .vmdl, .vmat, .vpcf, .vdata, .vsndevts, .vpost |
| KV3, binary | the payload of compiled _c resources in current games |
| DMX | Hammer's .vmap map sources, and .dmx exchange files from Blender or Maya |
| KeyValues, Source 1 style | configuration that predates KV3, such as gameinfo.gi and items_game.txt |
KeyValues2 is DMX's text encoding rather than a fifth format: a binary .vmap and the copy Hammer saves as text are the same DMX document in two encodings.
Not everything is compiled. Shipped paks also carry files the engine reads directly: KeyValues text scripts, Lua scripts in the games that use vscript, and DMX session data in Dota 2.
In this section
- Asset Types - Every Source 2 asset type, its source file extension, and the compiler that produces the compiled form.
- VPK - Valve Pak, the archive format Source ships content in, its header, directory tree, chunk files, hashes and signature.
- KV3 - KeyValues 3, its text form, its binary encodings and where each one is used.
- KV2/DMX - Valve's strongly typed, generic object graph data structure.
- VMAP - Example vmap
- CS2 detail_prop_types.vdata - CS2 detail props.