How to Set a Legal PID in PKHeX: What You Need to Know

If you've spent any time editing Pokémon saves with PKHeX, you've probably run into the term PID — and quickly realized it's one of the more technical fields in the editor. Set it wrong, and your Pokémon can trigger a hack check or behave unexpectedly in-game. Set it correctly, and everything looks legitimate. Here's a clear breakdown of what PIDs are, how they work, and what factors determine whether yours is legal.

What Is a PID in Pokémon?

PID stands for Personality ID — a 32-bit hexadecimal value assigned to every Pokémon when it's generated by the game. It's not just a random number. In older Generation games (Gen 3 through Gen 5 especially), the PID is deeply tied to several key characteristics:

  • Nature — determined by PID % 25
  • Gender — derived from the PID against a species' gender ratio
  • Ability — in Gen 3–4, the final bit of the PID determines which ability slot is used
  • Shininess — calculated by XOR-ing the PID with the Trainer ID (TID) and Secret ID (SID)
  • Unown letter and Spinda spots — cosmetic but PID-dependent

In Generation 6 and later, the relationship between PID and these traits was largely decoupled. Nature, gender, and ability are stored independently, which makes setting a legal PID significantly simpler in those generations.

Why Does Legality Matter?

Tools like PKHeX include a built-in legality checker (the green ✅ or red ❌ you see after editing). Third-party apps and online validators like PKHeX's ALM plugin or Legality API go even further. If your PID doesn't match the expected values for that Pokémon's nature, gender, ability, shiny status, and origin game, the legality check will flag it.

More practically: some Pokémon HOME checks, battle formats, and trade communities verify legality before accepting a Pokémon. A mismatched PID is one of the more common ways an edited Pokémon gets flagged.

How PID Generation Works by Generation

GenerationPID ControlsHow to Set Legally
Gen 3Nature, gender, ability, shininess, UnownMust match all traits; use a PID generator
Gen 4Same as Gen 3, plus egg shininess rulesLCRNG or MTRNG depending on method
Gen 5Same + stricter method checksMethod-specific; PKHeX can auto-generate
Gen 6+PID largely decorativePKHeX auto-assigns; manual entry rarely needed
Gen 8+EC replaces PID for most functionsPKHeX handles this automatically

Setting a Legal PID in PKHeX: The Core Methods

Method 1 — Let PKHeX Auto-Generate

For most modern games (Gen 6 onward), the simplest approach is to let PKHeX handle it. When you create or edit a Pokémon and click "Randomize PID" or use the "Set" button after filling in all other fields, PKHeX will attempt to assign a PID consistent with the Pokémon's traits.

Always run the legality check afterward. If you see an error specifically about the PID, that's your signal to use a more targeted method.

Method 2 — Use a RNG-Correct PID Generator (Gen 3–5)

For older games, a PID that's merely numerically consistent isn't always enough. The PID must also have been plausibly generated by the game's RNG algorithm — either LCRNG (Linear Congruential RNG, used in Gen 3–4) or MTRNG (Mersenne Twister, used in Gen 5).

Tools commonly used alongside PKHeX for this purpose include:

  • RNG Reporter — generates valid PIDs for Gen 3–4 based on method, nature, and shininess requirements
  • Pokéfinder — cross-platform alternative with Gen 3–5 support
  • 3DSRNGTool — for Gen 6–7 if you need exact spread matching

The workflow is: generate a valid PID in the RNG tool based on your desired traits → copy it into the PID field in PKHeX → verify legality.

Method 3 — Manual Hex Calculation

If you understand the underlying math, you can calculate a PID manually:

  • Choose your desired nature (0–24) and ensure PID % 25 = nature value
  • Check gender consistency against the species gender ratio
  • XOR the PID with your TID/SID to confirm or deny shininess: (TID XOR SID XOR PID_upper XOR PID_lower) < 8 = shiny in Gen 3–5

This method is precise but unforgiving. A single off-by-one error fails the check. It's typically only worth doing if you're building a very specific spread and need full control.

Variables That Affect Which Method You Need 🎮

Several factors determine which approach is appropriate for your situation:

Origin game is the biggest one. A Pokémon claiming to be from FireRed needs a PID consistent with Gen 3 LCRNG. One from Black 2 needs a Gen 5-appropriate value. PKHeX's legality checker knows these rules — it's not fooled by a numerically valid PID applied to the wrong method.

Shiny status adds complexity. If the Pokémon is shiny, the PID must produce a shiny result when calculated against your TID and SID. In Gen 6+, shiny PIDs use a different flagging system entirely.

Egg vs. wild vs. event origin each have distinct PID generation patterns in older games. An egg Pokémon from Gen 4 has PID rules tied to the Masuda Method or standard breeding — and those differ from wild encounters.

Your TID and SID matter in Gen 3–5 specifically because shininess is trainer-relative. A PID that's shiny for one trainer file won't be shiny for another.

Technical skill level is a real variable here. The manual hex approach and RNG tool workflows assume familiarity with hexadecimal values and RNG mechanics. PKHeX's auto-generation is the accessible starting point — but it has limits, particularly for edge cases in older generations.

What the Legality Checker Is Actually Telling You

When PKHeX flags a PID error, the message usually specifies why — whether it's a nature mismatch, an incorrect method signature, or a shiny inconsistency. Reading that error precisely tells you which variable to fix. A generic "PID mismatch" in Gen 3 almost always means the PID wasn't generated by the correct RNG method for that encounter type, not just that the number is wrong.

Understanding the specific error is what separates a fixable edit from one that requires starting the Pokémon over with a freshly generated spread.

The right approach for your PID ultimately depends on which game you're editing for, whether the Pokémon needs to be shiny, what origin and encounter type you're targeting, and how closely you need it to match a legitimate RNG result — all of which vary from one save file to the next. 🔍