From Minecraft Wiki
Sets a player's game mode.
- Java Edition
gamemode <mode> [player]
- Pocket Edition
gamemode <gameMode: string> [player: target]
- An alternate syntax allows player to enter game mode by its number:
gamemode <gameMode: int> [player: target]
- mode (PE: gameMode: string or gameMode: int)
- "hardcore" is not a valid option for the mode argument, as it is technically not a game mode.
- player (PE: player: target) (optional)
- If specified, must be either a player's username or a target selector. If unspecified, defaults to the player using the command. When used in a command block, player is not optional.
- Fails if the arguments are not specified correctly, or if player fails to resolve to one or more online players.
- If successful, changes the game mode of the default or specified players.
- To put yourself into creative mode:
gamemode c, or
- To put all players into survival mode:
gamemode 0 @a
- See also
- defaultgamemode – sets the initial game mode for players joining the world