In early 2025, the indie developer Pieter Levels built a 3D flight simulator that runs in a web browser in a few hours, using an AI code editor and the three.js library, with no game-development background. It went viral, and “vibe coding” (describing what you want and letting AI write the code) went mainstream with it.
You don’t need to go viral to have fun with this. A small, playable browser game is now a realistic weekend project for a beginner. Here’s how to build a browser game with AI, step by step, and where people usually go wrong.
What you’ll need
- An AI assistant that can write code. A chat assistant such as ChatGPT, Claude or Gemini works for a single-file game. AI code editors such as Cursor, GitHub Copilot or Claude Code are better once your project grows past one file.
- A game library. Don’t let the AI start from nothing. Ask it to use a popular browser library, because models have seen far more code for these and make fewer mistakes:
- Phaser for 2D games (platformers, shooters, puzzles).
- three.js for 3D.
- Babylon.js for 3D with more game features built in.
- A browser and a text editor. Any modern browser runs the game; a free editor like VS Code makes it easier to see and change the files.
Step 1: Pick a tiny game
The most common beginner mistake is asking for too much. “An open-world RPG” will produce a mess; “a one-screen game where you dodge falling rocks” will produce something you can play in ten minutes.
Good first projects have one verb (jump, dodge, shoot, match, steer), one screen, and one way to win or lose. Classics like Snake, Breakout, Flappy Bird or a simple endless runner are ideal, because the AI knows them well and you’ll notice quickly if something’s wrong.
Step 2: Write a one-paragraph brief
Before you prompt, write down what the game is in a few sentences. Then turn it into a prompt that covers:
- The game: what the player does and what makes them win or lose.
- The controls: keyboard, mouse, touch, or all three.
- The tech: “a single HTML file using Phaser 3 from a CDN” (or three.js), so it runs by double-clicking the file.
- The screens: a start screen, the game, and a game-over screen with the score and a restart button.
- The look: simple coloured shapes are fine for a first version; you can add art later.
For example: “Make a browser game in a single HTML file using Phaser 3 from a CDN. The player moves a paddle left and right with the arrow keys or by dragging on a touchscreen. Rocks fall from the top at increasing speed. Catching gems adds points; getting hit by a rock ends the game. Include a start screen, a score in the corner, and a game-over screen with a restart button. Use simple coloured shapes.”
Step 3: Run it, then fix one thing at a time
Save the code as index.html and open it in your browser. Something will be wrong: that’s normal. Fix it in small steps:
- Describe bugs precisely. “When the score reaches 10, the rocks stop falling” gets a fix. “It’s broken” gets guesswork.
- Paste errors in full. Open the browser’s developer tools (F12 on most computers), copy the red error from the Console tab, and give it to the AI.
- Change one thing per request. Asking for five changes at once makes it hard to tell which one broke something.
- Keep working copies. Save a copy each time the game works (
v1.html,v2.html), so you can go back when a change goes wrong.
Step 4: Make it feel good
A game that works isn’t the same as a game that’s fun. This is where your judgement matters more than the AI’s. Play it and ask yourself:
- Is it too easy or too hard in the first 30 seconds?
- Does every action have feedback: a sound, a flash, a little shake?
- Is it obvious what to do without reading instructions?
Then ask for specific tweaks: “make the rocks fall 20% slower for the first ten seconds”, “add a short screen shake when the player is hit”, “add a sound when a gem is caught, using the Web Audio API”.
Step 5: Test it on a phone
Most casual browser games are played on phones, and a game that runs well on your laptop can stutter or be unplayable on a cheap phone. Put the file online (see the next step) and open it on a real phone. Check that touch controls work, that the game fits the screen in the orientation you designed for, and that it stays smooth.
Step 6: Publish it
A browser game is just files, so you can put it online for free:
- itch.io: upload a zip of your HTML game and it gets its own page. It’s the easiest place to share small games, but read its current rules on AI-generated content before you upload.
- A free static host such as Cloudflare Pages, GitHub Pages or Netlify. Here’s how to host a static site on Cloudflare Pages, which works the same way for a game.
- Game portals, if the game is polished. They review submissions and share ad revenue, but each has its own rules (below).
The rules that catch people out
| Platform | What it says about AI and promotion |
|---|---|
| Poki | Encourages thoughtful AI use but says AI content must add value, not replace craft, and warns that games made solely with AI can raise IP ownership issues |
| CrazyGames | No specific AI rule in its public docs, but games must not cross-promote other games or platforms |
| Steam | Requires developers to disclose generative AI used in the game |
| Playdate (Catalog) | Stopped accepting games made with certain kinds of generative AI in 2026 |
Policies change often, so check each platform’s current developer pages before you submit. Also avoid obvious copies of existing hits: portals commonly reject duplicate or templated games, low-quality builds and anything with unclear copyright.
What AI is good at, and what it isn’t
AI is very good at the mechanical parts: game loops, collisions, scoring, menus, saving high scores, and fixing a bug you describe clearly. It’s much weaker at the parts that make a game worth playing: knowing what’s fun, getting the feel of a jump or a hit right, keeping things fast on old phones, and coming up with an original twist. Left to itself, it reaches for the most common version of everything.
So treat it as a fast, tireless programmer who needs a good designer. The designer is you. If you’re curious how studios are using the same tools, and why many developers are uneasy about it, read how AI is changing game development. And for inspiration, browse these free browser games you can play right now.
FAQ
Do I need to know how to code?
Not to get started, but a little knowledge goes a long way. You'll need to read error messages, describe bugs precisely, and understand roughly how the pieces of a game fit together, or you'll get stuck the first time something breaks.
Do I own a game the AI wrote?
It's a grey area that depends on where you live and how much of the work is yours. Poki warns that games created solely with AI can raise IP ownership issues. The more you design, edit and add yourself, the stronger your position.
Which AI is best for writing games?
Any of the major assistants (ChatGPT, Claude or Gemini) or an AI code editor like Cursor or GitHub Copilot can write a small browser game. What matters more is choosing a well-known library such as Phaser or three.js, which these models have seen a lot of.
SOURCES
- Cinevva: Vibe coding games, what it is and how to start (June 2026)
- SpriteCook: How to vibe code a browser game with Phaser.js (April 2026)
- Abratabia: How to make a game with AI, a realistic guide (June 2026)
- Poki for Developers: Working with AI
- CrazyGames: Gameplay requirements
- PC Gamer: Valve updates its Steam policy on AI
- Playgama: Why do web game portals reject AI-generated or assisted games?
- Pulse / PC Gamer: Playdate will no longer accept games made with generative AI (April 2026)



