The Teams class provides methods for converting between different team formats and generating random teams in Pokemon Showdown.
Pokemon Showdown uses three team formats:
Export Format Human-readable format for import/export
JSON Format Structured format using PokemonSet[]
Packed Format Compressed format for transmission/storage
PokemonSet Interface
The PokemonSet interface represents a single Pokemon’s configuration:
interface PokemonSet {
name : string ; // Nickname
species : string ; // Species name (e.g., "Minior-Red")
item : string ; // Held item
ability : string ; // Ability name
moves : string []; // Array of move names
nature : string ; // Nature name
gender : string ; // "M", "F", or ""
evs : StatsTable ; // Effort Values (0-255)
ivs : StatsTable ; // Individual Values (0-31)
level : number ; // Level (1-100, supports up to 9999)
shiny ?: boolean ; // Shiny status
happiness ?: number ; // Happiness value (0-255)
pokeball ?: string ; // Pokeball type
hpType ?: string ; // Hidden Power type
dynamaxLevel ?: number ; // Dynamax level (0-10)
gigantamax ?: boolean ; // Gigantamax capable
teraType ?: string ; // Tera type
}
Methods
pack()
Converts a JSON team to packed format (compressed string).
Teams . pack ( team : PokemonSet [] | null ): string
Array of Pokemon sets to pack, or null
Packed team string, or empty string if team is null
Example
Packed Format Structure
import { Teams } from './sim/teams' ;
const team = [{
name: 'Articuno' ,
species: 'Articuno' ,
item: 'Leftovers' ,
ability: 'Pressure' ,
moves: [ 'Ice Beam' , 'Hurricane' , 'Substitute' , 'Roost' ],
nature: 'Modest' ,
evs: { hp: 252 , atk: 0 , def: 0 , spa: 252 , spd: 4 , spe: 0 },
ivs: { hp: 31 , atk: 31 , def: 31 , spa: 30 , spd: 30 , spe: 31 },
level: 100 ,
gender: ''
}];
const packed = Teams . pack ( team );
console . log ( packed );
// Output: Articuno||leftovers|pressure|icebeam,hurricane,substitute,roost|Modest|252,,,252,4,||,,,30,30,|||
unpack()
Converts a packed team string to JSON format.
Teams . unpack ( buf : string ): PokemonSet [] | null
Packed team string to unpack. Can also accept JSON string format.
Array of Pokemon sets, or null if invalid
import { Teams } from './sim/teams' ;
const packed = 'Articuno||leftovers|pressure|icebeam,hurricane,substitute,roost|Modest|252,,,252,4,||,,,30,30,|||' ;
const team = Teams . unpack ( packed );
console . log ( team [ 0 ]. species ); // "Articuno"
console . log ( team [ 0 ]. ability ); // "Pressure"
console . log ( team [ 0 ]. moves ); // ["Ice Beam", "Hurricane", "Substitute", "Roost"]
The unpack() method has a limit of 24 Pokemon per team for simulator compatibility.
export()
Converts a JSON team to human-readable export format.
Teams . export ( team : PokemonSet [], options ?: ExportOptions ): string
Array of Pokemon sets to export
Export options Hide EVs, IVs, and nature from export
removeNicknames
boolean | (nickname: string) => string | null
Remove or transform nicknames. If true, removes all nicknames. If function, transforms each nickname.
Human-readable team string in export format
Basic Usage
Output
Hide Stats
Remove Nicknames
import { Teams } from './sim/teams' ;
const team = [{
name: 'Articuno' ,
species: 'Articuno' ,
item: 'Leftovers' ,
ability: 'Pressure' ,
moves: [ 'Ice Beam' , 'Hurricane' , 'Substitute' , 'Roost' ],
nature: 'Modest' ,
evs: { hp: 252 , atk: 0 , def: 0 , spa: 252 , spd: 4 , spe: 0 },
ivs: { hp: 31 , atk: 31 , def: 31 , spa: 30 , spd: 30 , spe: 31 },
level: 100 ,
gender: ''
}];
const exported = Teams . export ( team );
console . log ( exported );
exportSet()
Converts a single Pokemon set to export format.
Teams . exportSet ( set : PokemonSet , options ?: ExportOptions ): string
Single Pokemon set to export
Same export options as export()
Human-readable Pokemon set string
import { Teams } from './sim/teams' ;
const set = {
name: 'Frosty' ,
species: 'Articuno' ,
item: 'Leftovers' ,
ability: 'Pressure' ,
moves: [ 'Ice Beam' , 'Hurricane' ],
nature: 'Modest' ,
evs: { hp: 252 , atk: 0 , def: 0 , spa: 252 , spd: 4 , spe: 0 },
ivs: { hp: 31 , atk: 31 , def: 31 , spa: 31 , spd: 31 , spe: 31 },
level: 100 ,
gender: 'F'
};
const exported = Teams . exportSet ( set );
// Output:
// Frosty (Articuno) (F) @ Leftovers
// Ability: Pressure
// EVs: 252 HP / 252 SpA / 4 SpD
// Modest Nature
// - Ice Beam
// - Hurricane
import()
Converts a team from any string format (export, packed, or JSON) to JSON format.
Teams . import ( buffer : string , aggressive ?: boolean ): PokemonSet [] | null
Team string in any format (export, packed, or JSON)
If true, uses toID() for sanitization instead of Dex.getName(). This converts all names to IDs (lowercase, no spaces).
Array of Pokemon sets, or null if invalid
From Export Format
From Packed Format
From JSON Format
Aggressive Mode
import { Teams } from './sim/teams' ;
const exported = `
Articuno @ Leftovers
Ability: Pressure
EVs: 252 HP / 252 SpA / 4 SpD
Modest Nature
- Ice Beam
- Hurricane
` ;
const team = Teams . import ( exported );
console . log ( team [ 0 ]. species ); // "Articuno"
The import() method automatically detects the format and converts appropriately. It handles export format (newline-separated), packed format (pipe-separated), and JSON format (array).
generate()
Generates a random team for a specific format.
Teams . generate ( format : Format | string , options ?: PlayerOptions | null ): PokemonSet []
Format name or Format object (e.g., “gen9randombattle”)
Generation options PRNG seed for reproducible team generation (array of 4 numbers)
Generated team as array of Pokemon sets
Basic Usage
With Seed
Different Formats
import { Teams } from './sim/teams' ;
const team = Teams . generate ( 'gen9randombattle' );
console . log ( team . length ); // 6 (or format-specific team size)
console . log ( team [ 0 ]. species ); // Random species
getGenerator()
Gets a team generator instance for a specific format.
Teams . getGenerator ( format : Format | string , seed ?: PRNG | PRNGSeed | null ): TeamGenerator
Format name or Format object
PRNG instance or seed for reproducible generation
Team generator instance for the specified format
import { Teams } from './sim/teams' ;
const generator = Teams . getGenerator ( 'gen9randombattle' );
const team = generator . getTeam ();
// You can generate multiple teams from the same generator
const team2 = generator . getTeam ();
Utility Methods
packName()
Converts a name to packed format (removes special characters, keeps case).
Teams . packName ( name : string | undefined | null ): string
name
string | undefined | null
Name to pack
Packed name with only alphanumeric characters
import { Teams } from './sim/teams' ;
console . log ( Teams . packName ( 'Farfetch \' d' )); // "Farfetchd"
console . log ( Teams . packName ( 'Ho-Oh' )); // "HoOh"
console . log ( Teams . packName ( 'Mr. Mime' )); // "MrMime"
Unlike toID(), packName() preserves case. This is important for distinguishing between species names and IDs in packed format.
unpackName()
Attempts to recover a readable name from a packed name.
Teams . unpackName ( name : string , dexTable ?: { get : ( name : string ) => AnyObject }): string
dexTable
{ get: (name: string) => AnyObject }
Dex table (e.g., Dex.species, Dex.items) for accurate name lookup
Readable name with spaces added
import { Teams , Dex } from './sim' ;
// With dex table (accurate)
console . log ( Teams . unpackName ( 'dragondance' , Dex . moves )); // "Dragon Dance"
console . log ( Teams . unpackName ( 'leftovers' , Dex . items )); // "Leftovers"
// Without dex table (guess)
console . log ( Teams . unpackName ( 'HoOh' )); // "Ho Oh"
console . log ( Teams . unpackName ( 'MrMime' )); // "Mr Mime"
Usage Examples
import { Teams } from './sim/teams' ;
// Export to Packed
const packedTeam = 'Articuno||leftovers|pressure|icebeam,hurricane|Modest|252,,,252,4,|||||' ;
const jsonTeam = Teams . unpack ( packedTeam );
const exportedTeam = Teams . export ( jsonTeam );
// Export to Packed
const backToPacked = Teams . pack ( jsonTeam );
// Import any format
const team1 = Teams . import ( packedTeam );
const team2 = Teams . import ( exportedTeam );
const team3 = Teams . import ( '[{"species":"Articuno"}]' );
Working with Team Data
import { Teams } from './sim/teams' ;
const team = Teams . unpack ( 'Articuno||leftovers|pressure|icebeam,hurricane|Modest|252,,,252,4,|||||' );
// Modify team
team [ 0 ]. moves . push ( 'Substitute' );
team [ 0 ]. evs . spe = 252 ;
team [ 0 ]. evs . spa = 0 ;
// Export modified team
const modified = Teams . export ( team );
console . log ( modified );
Generating Teams for Testing
import { Teams , PRNG } from './sim' ;
// Generate consistent test teams
const testSeed = [ 0x12345678 , 0x9abcdef0 , 0x11111111 , 0x22222222 ];
const team1 = Teams . generate ( 'gen9ou' , { seed: testSeed });
const team2 = Teams . generate ( 'gen9ou' , { seed: testSeed });
// team1 and team2 are identical
console . log ( JSON . stringify ( team1 ) === JSON . stringify ( team2 )); // true
See Also
Team Validator - Validate teams for format legality
Dex - Access Pokemon data
PRNG - Pseudo-random number generation