Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VDF2

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.

Features

  • 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

Installation

pip install vdf2

Requires Python 3.14+.

Usage

Parse a VDF string

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'}
#     }
# }

Parse from a file

with open("config.vdf") as fp:
    data = vdf2.load(fp)

Serialize to a VDF string

text = vdf2.dumps(data)

Serialize to a file

with open("config.vdf", "w") as fp:
    vdf2.dump(data, fp)

API reference

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.

License

MIT

About

VDF parser for Python

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages