keyvalues-tools
TypeScript
// Overview
Zero-dependency TypeScript parser and serializer for Valve KeyValues, both KV1/VDF and KV3 (Source 2 / CS2). Read, edit, validate and convert game config with a comment-preserving AST and a CLI.
// Built with
TypeScriptNode.jsBunzero-depKeyValues
// The problem
Valve's KeyValues formats are everywhere in Source games, but existing parsers only cover the old text format and lose comments, order and precision on round-trips.
// Approach
- A pure-TypeScript parser and serializer for both KV1/VDF and KV3, auto-detected from the file header.
- A comment, order and conditional preserving AST, so you can edit a value and write the file back faithfully.
- Schema validation, dot-path get/set/diff/merge and a CLI, all with no runtime dependencies.
// Engineering challenges
- Implementing the KV3 grammar by hand: typed values, arrays, multi-line strings, flags and every comment style.
- Keeping SteamID64s and oversized integers exact instead of losing precision to floating point.
- Verifying correctness against real CS2 behavior-tree files, not just synthetic examples.