How to Build a Game with ChatGPT
How to build a game with ChatGPT, from the first prompt to a playable browser game, with image prompts for game art and the point where chat stops being enough.
ChatGPT can write a small, complete game in one reply and let you play it without leaving the chat. That makes it the quickest way to go from an idea to something on screen, and a good place to learn how building with AI works.
This guide shows how to build a game with ChatGPT step by step: setting up a project, writing the first prompt, playing the result in the chat, improving it, making art, and sharing it. It also covers where a chat thread stops being the right tool. Features and plan details were checked against OpenAI's help pages on November 14, 2026, and several have changed this year.
What changed in 2026
If you have followed an older tutorial, three things will look different.
Canvas is gone. ChatGPT's side-by-side editor was removed from current models. OpenAI's release notes say writing and coding are "now supported directly in chat responses through writing blocks and code blocks."
You preview games from a code block. OpenAI's help page explains: "For supported code blocks, select Preview to view the result inside ChatGPT." HTML pages are on the supported list. It adds: "If Preview does not appear, the code block does not support a preview."
Custom GPTs are no longer for personal accounts. The free tier FAQ states that "new GPT creation and publishing are not available on personal ChatGPT accounts, including Free, Go, Plus, and Pro." Guides that tell you to build a "game maker GPT" no longer apply. Use Projects, covered below.
What you need
| Plan | Price | For game building |
|---|---|---|
| Free | $0 | Text chat, code blocks with Preview, image creation with limits, 5 files per project |
| Plus | $20 a month | Stronger models, 25 files per project, Codex on the web, and Sites for hosting |
Start free. OpenAI says free users have "unlimited everyday text chats," while "file uploads, image generation, voice, data analysis, and other tools have separate usage limits." It does not publish exact numbers for those limits.
Step 1: Create a Project for your game
A long chat drifts. Details from early on get lost, and the game starts changing in ways you did not ask for. Projects help with that.
OpenAI describes Projects as a way to "keep related chats, files, and instructions together." Create one for your game and add project instructions. These apply to every chat inside the project.
Paste something like this into the project instructions:
This project is a small browser game called [name].
Pitch: [one sentence]
Core loop: [verb > verb > verb]
Controls: [keys or touch]
Style: [simple flat shapes / pixel art / other], palette [colours]
Rules for every reply:
- Keep the whole game in one self-contained HTML file with inline CSS and JavaScript. No external libraries or files unless I ask.
- When you change the game, return the complete updated file, not a fragment.
- Make only the change I ask for. Do not add features on your own.
- After the code, list what changed in two or three bullet points.
- Put all tunable numbers (speed, gravity, spawn rate) in one clearly marked block at the top of the script.You can also upload reference files, such as a design document or art. The free tier allows 5 files per project, and Plus allows 25.
If you do not have a design yet, our one-page game design document template is a good thing to fill in and upload.
Step 2: Write the first prompt
Ask for the smallest playable version. One mechanic, plain shapes, a way to win or lose.
Build the first playable version of my game as one self-contained HTML file using a canvas.
The game: a top-down game where the player is a small boat collecting floating bottles while avoiding rocks.
Controls: arrow keys or WASD to move.
Rules:
- The boat moves at a steady speed and cannot leave the screen.
- Ten bottles appear at random positions. Collecting one adds 1 to the score.
- Five rocks drift slowly across the screen. Touching a rock ends the game.
- Collect all ten bottles to win.
- Show the score at the top. On win or loss, show a message and "Press R to restart".
Looks: flat shapes only. Blue background, white boat, green bottles, grey rocks.
Do not add menus, sound, levels or animations yet.ChatGPT will reply with a code block. Select Preview on the block to play the game in the chat. If you do not see a Preview button, copy the code into a file named game.html on your computer and open it in a web browser. The game is the same either way.
Step 3: Play, then ask for one change at a time
Play the game for a few minutes. Write down what feels wrong. Then fix things one at a time.
Be specific about what you saw and what you want:
- "The boat feels slow. Increase its speed by half."
- "Rocks sometimes appear on top of the boat at the start. Make sure no rock starts within 150 pixels of the boat."
- "When I win, the rocks keep moving behind the message. Freeze everything when the game ends."
If something breaks, describe the symptom. "After the last change, pressing R does nothing" is all ChatGPT needs. If a change makes the game worse, say "undo the last change and return the previous version."
Once the basics feel right, build up in small steps:
The core game works well. Add these one at a time, returning the full file each time, and wait for me to test before the next:
1. A start screen with the title and "Press space to begin".
2. A 60-second timer. Running out of time ends the game.
3. Rocks that speed up slightly every time I collect a bottle.
4. Simple sound effects made with the Web Audio API, so there are no audio files: a blip for a bottle, a low thud for a crash.
5. Touch controls so it works on a phone.Step 4: Make the art with ChatGPT
ChatGPT also creates images, on every plan. For games, three features are useful, all described on OpenAI's images help page.
Transparent backgrounds. ChatGPT Images "can follow instructions to add text, add details within the image, or make the background transparent." A transparent background is what you need for a sprite, the picture of a character or object that sits on top of the game's background.
Consistency between edits. The current version "does a better job of keeping details consistent from one edit to the next," which helps when you need the same character in several poses.
Animation. "GIF creation is rolling out in ChatGPT. Ask for a looping GIF and describe what should move."
A prompt for a sprite:
Create a game sprite: a small wooden rowing boat seen from directly above.
Style: flat colours, thick dark outline, no shading, no text.
Background: transparent.
Framing: the boat centred, filling most of a square image, pointing up.
I will use this at about 64 pixels wide in a top-down browser game, so keep the shapes simple and readable at small size.Then ask for the rest in the same style: "Now a green glass bottle and a grey rock in exactly the same style, each on a transparent background."
To use the images, download them, put them in the same folder as your game.html, and ask ChatGPT to update the game to draw those files instead of shapes. At this point your game is more than one file, which leads to the next step.
Concept art is a different job from sprites. For key art, a logo and the overall look, see the branding section of how to build a game with AI.
Step 5: Share the game
The simple route: a single HTML file can be uploaded as a browser game to itch.io, or hosted on any static web host. This works on the free plan.
ChatGPT Sites. On Plus and above, ChatGPT can host what you build. OpenAI's Sites documentation says: "You can also host web apps, games, or a compatible project you've already built." To start, the help page says: "Include the word 'website' in your prompt, or mention @Sites." A few details from the help page:
- "Sites is not available on Free or Go."
- "New Sites are private by default," and you choose when to make one public.
- "Hosting is free through December 31, 2026." After that, hosting draws on a monthly allowance.
Where a chat thread stops working
Chat is excellent for a small game. It struggles as the game grows, for a few reasons.
Long games overflow the reply. Once the file reaches many hundreds of lines, getting the whole thing back each time is slow, and partial replies are easy to paste wrongly.
Multiple files are awkward. Images, sounds and separate code files have to be passed back and forth by hand.
The chat forgets. In a long thread, early decisions fade. Project instructions help, but they do not fully solve it.
It cannot test for you. In chat, you are the one playing and reporting bugs.
Publishing and saving progress need more than a chat. High scores across players, accounts and updates all need real hosting.
When you hit these, move to a coding agent. OpenAI's is called Codex. It works on a folder of real files, runs the game and makes changes across many files at once. According to OpenAI's Codex pricing page, Plus includes "Codex on the web, in the CLI, in the IDE extension, and on iOS." Other options include Cursor and Claude Code, which we compare in Cursor vs Claude Code for game building.
Your ChatGPT game is a good starting point for that move. Save the HTML file into a folder, open the folder in the agent, and carry on from there.
How ChatGPT compares for games
ChatGPT's strengths for game building are the instant preview, built-in image creation with transparent backgrounds, and a free tier that is enough to make something real. Other assistants have different strengths. Claude is a popular choice for 3D browser games, and Google offers video and music generation alongside Gemini.
Our comparison of Gemini, Claude and ChatGPT for game building goes through the differences. If you want to try 3D next, the Three.js tutorial is the place to start.
Tips that save time
- Keep numbers in one place. With speed, gravity and timers in one block at the top, you can tune the game yourself without asking.
- Save versions. Each time the game works, save the file with a new name:
game-v1.html,game-v2.html. A working copy to go back to is worth a lot. - Start a new chat when things get muddled. Inside the same Project, open a fresh chat, paste the current file and continue. The project instructions carry over.
- Ask why. If you are curious how something works, ask ChatGPT to explain that part of the code in plain language. You will write better prompts once you understand the pieces.
- Do not expect a store-ready game from one prompt. Expect a small game that works, and build from there.
From a chat to a project
A game that lives in a chat thread is hard for anyone else to find. Once yours is playable, give it a public home: a page with the pitch, the art and a link to play, where people can follow along as you improve it.