Format:PK3
| On this wiki | Facts · Code · Notes · Topics |
|---|
Gen 3 Pokémon entity (.pk3; 80 bytes stored in boxes, 100 in the party): PID and OT id first, a 32-byte header, then four 12-byte substructures whose order depends on PID % 24, XOR-encrypted with PID ^ OT id; the checksum is a 16-bit sum of the 48 data bytes.
The Pokémon record of Format:Pokémon Generation 3 save file. Layout read from Tool:PKHeX (PK3.cs, PokeCrypto.cs).
Sizes
80 bytes stored (PC boxes, daycare), 100 bytes in the party (20 extra bytes of battle stats, not encrypted). PKHeX also knows 196-byte XD and 312-byte Colosseum variants.
Header (0x00-0x1F, never encrypted)
| Offset | Field |
|---|---|
| 0x00 | personality value (PID) u32 |
| 0x04 | OT id: trainer id u16 then secret id u16 (together the u32 used for encryption) |
| 0x08 | nickname, 10 bytes, Gen 3 text encoding |
| 0x12 | language |
| 0x13 | flags: bit 0 bad egg, bit 1 has species, bit 2 egg |
| 0x14 | OT name, 7 bytes |
| 0x1B | markings |
| 0x1C | checksum u16 |
| 0x1E | u16 (PKHeX calls it sanity) |
Data (0x20-0x4F): four substructures of 12 bytes
Names: G (growth), A (attacks), E (EVs and condition), M (miscellaneous). Offsets are those of the decrypted, canonical order G A E M:
- G at 0x20: species u16 (an internal index, not the national dex number), held item u16, experience u32, PP ups byte (2 bits per move), friendship byte, 2 more bytes.
- A at 0x2C: four moves u16, four PP bytes.
- E at 0x38: EVs HP/Atk/Def/Spe/SpA/SpD (6 bytes), contest stats cool/beauty/cute/smart/tough/sheen (6 bytes).
- M at 0x44: Pokérus byte, met location byte, origins u16 (bits 0-6 met level, 7-10 game of origin, 11-14 ball, bit 15 OT gender), IV word u32 (5 bits each in the order HP, Atk, Def, Spe, SpA, SpD from bit 0; bit 30 egg flag; bit 31 ability slot), ribbon word u32 (bit 31 fateful encounter).
Party extra, 0x50-0x63: status condition u32, level, mail id, current HP, max HP, Atk, Def, Spe, SpA, SpD (u16 each). Struct fact: Fact:PK3/struct/PK3 stored layout.
Encryption
Decrypting an entity: seed = PID ^ OT id (the u32 at offset 4); XOR each u32 of the 48 data bytes with the seed; then un-shuffle the four blocks according to PID % 24. The 24 orders are the permutations of G A E M in lexicographic order (index 0 GAEM, 1 GAME, 2 GEAM, 3 GEMA ... 23 MEAG). Steps and the checksum: Fact:PK3/behavior/PK3 substructure encryption and checksum.
The checksum is the 16-bit sum (mod 0x10000) of the 24 little-endian u16 of the decrypted data, stored at 0x1C.
Later generations
Format:PK4 and PK5 replace the plain XOR with a per-word PRNG stream; Format:PK8, PA8 and PK9 use larger blocks and a header with an encryption constant.
Unverified: the lexicographic order of the 24 permutations is derived from PKHeX's table, which stores for each PID % 24 the file position of each of G, A, E, M (the inverse permutation); check it against a real save before relying on it.
Code & repositories
- https://github.com/kwsch/PKHeX @
641c26ba100225f3605e5a44b61b3b16e15a3774· license: GPL-3.0 (declared by the contributor; GitHub's detector did not recognize LICENSE)
Pokémon save and entity editor; PKHeX.Core is the reference for save sectors, checksums and PK3-PK9 encryption (PokeCrypto.cs, SAV3.cs, PK3.cs, SAV1.cs, SAV2.cs).
Tested on: source read, not run: source read, not run · checked 2026-10-18