Use SaveUtil.GetVariantSAV to detect and load any Pokémon save file:
using PKHeX.Core;byte[] data = File.ReadAllBytes("path/to/save.sav");var sav = SaveUtil.GetVariantSAV(data);if (sav == null){ Console.WriteLine("Invalid save file!"); return;}Console.WriteLine($"Loaded: {sav.GetType().Name}");Console.WriteLine($"OT: {sav.OT}");Console.WriteLine($"Game: {sav.Version}");
3
Access and modify Pokémon
Read Pokémon from boxes and modify their properties:
// Get the first Pokémon from Box 1var pk = sav.GetBoxSlotAtIndex(0, 0);Console.WriteLine($"Species: {pk.Species}");Console.WriteLine($"Level: {pk.CurrentLevel}");Console.WriteLine($"Nickname: {pk.Nickname}");// Modify the Pokémonpk.CurrentLevel = 100;pk.Nickname = "CHARIZARD";// Write it back to the savesav.SetBoxSlotAtIndex(pk, 0, 0);
4
Validate and export
Check legality and save your changes:
// Validate the Pokémonvar la = new LegalityAnalysis(pk);Console.WriteLine($"Legal: {la.Valid}");if (!la.Valid){ foreach (var result in la.Results) { Console.WriteLine($"- {result.Comment}"); }}// Export the modified savebyte[] exportData = sav.Write().ToArray();File.WriteAllBytes("path/to/modified.sav", exportData);
Key features
Everything you need to work with Pokémon save data
Multi-generation support
Work with save files from all Pokémon generations (1-9), including GameCube titles
Legality analysis
Comprehensive validation system to verify Pokémon legality and flag impossible data
Showdown integration
Import and export Pokémon Showdown text format for easy team sharing
Format conversion
Transfer Pokémon between generations with automatic format conversion
Mystery Gift support
Handle event distribution files and convert them to usable Pokémon entities
Type-safe API
Strongly-typed C# classes for every Pokémon format and save file structure