Skip to main content

PKHeX Documentation

A comprehensive C# library for editing and validating Pokémon save files and entity data across all generations.

Quick start

Get up and running with PKHeX.Core in minutes

1

Install the package

Add PKHeX.Core to your project via NuGet:
dotnet add package PKHeX.Core
Or using the Visual Studio Package Manager:
Install-Package PKHeX.Core
2

Load a save file

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 1
var pk = sav.GetBoxSlotAtIndex(0, 0);

Console.WriteLine($"Species: {pk.Species}");
Console.WriteLine($"Level: {pk.CurrentLevel}");
Console.WriteLine($"Nickname: {pk.Nickname}");

// Modify the Pokémon
pk.CurrentLevel = 100;
pk.Nickname = "CHARIZARD";

// Write it back to the save
sav.SetBoxSlotAtIndex(pk, 0, 0);
4

Validate and export

Check legality and save your changes:
// Validate the Pokémon
var 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 save
byte[] 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

Ready to start building?

Install PKHeX.Core from NuGet and start working with Pokémon save data in your C# projects today.

View installation guide

Build docs developers (and LLMs) love