A minimal, dependency-free Python parser and serializer for the Valve Data Format (VDF), the markup language used by Valve games (CS:GO, Dota 2, TF2) for configs, item schemas, and save files.
- Parse VDF strings and files into plain Python
dicts - Serialize
dicts back into VDF text - Handles nested dictionaries and escaped quotes (
\") - Strips
//line comments - Zero dependencies
pip install vdf2Requires Python 3.14+.
import vdf2
text = """
// configuration file
"App"
{
"Name" "Counter-Strike"
"Version" "1.6"
"Settings"
{
"Fullscreen" "1"
"Resolution" "1920x1080"
}
}
"""
data = vdf2.loads(text)
# {
# 'App': {
# 'Name': 'Counter-Strike',
# 'Version': '1.6',
# 'Settings': {'Fullscreen': '1', 'Resolution': '1920x1080'}
# }
# }with open("config.vdf") as fp:
data = vdf2.load(fp)text = vdf2.dumps(data)with open("config.vdf", "w") as fp:
vdf2.dump(data, fp)| Function | Description |
|---|---|
vdf2.loads(text) |
Parse a VDF string into a dict. |
vdf2.load(fp) |
Read a VDF from a file-like object and return a dict. |
vdf2.dumps(data) |
Serialize a dict into a VDF string. |
vdf2.dump(data, fp) |
Write a dict as VDF to a file-like object. |