You can find good free HTML5 game source code in three places: open-source games published on GitHub, starter templates from the engines themselves, and curated lists that collect both. This page lists the ones worth your time, each checked on 25 October 2026 against its GitHub repository and licence file, and explains what each licence lets you do. That second part matters more than most lists admit: half the "free" games on GitHub can't legally be sold, reskinned for a client or even reused without opening your own code.
We make and sell commercial HTML5 games, and we also publish free HTML game code under the MIT licence, so we've read a lot of licence files. Nothing here is legal advice; when money depends on it, ask a lawyer.
Where to find free HTML5 game source code
Start with what you need the code for:
| You want to | Best source | Typical licence |
|---|---|---|
| Learn how a game works | Short single-file games and tutorials | MIT, CC0 |
| Study a real, finished game | Open-source games on GitHub (list below) | MIT, GPL, MPL, AGPL |
| Start a new project fast | Official engine templates | MIT |
| Browse many options | Curated "awesome" lists and GitHub topics | Varies per game |
| Ship a commercial game quickly | A finished game with a commercial licence | Commercial |
For learning, our free HTML game code pages are a good first stop: complete one-file games such as Snake, Pong and Breakout, each with a tutorial, MIT-licensed and free to use in commercial projects. For everything else, read on.
15 open-source HTML5 games worth studying (checked October 2026)
How we picked: each game runs in a browser, has a public GitHub repository we opened on 25 October 2026, and is well known or still maintained. We read the actual LICENSE file and README for each one rather than trusting the badge. "Commercial reuse" summarises what the licence allows for the code; art, music and names can carry different terms, noted where they do.
| Game | Genre | Main tech | Licence | Commercial reuse |
|---|---|---|---|---|
| 2048 | Sliding puzzle | JavaScript | MIT | Yes, keep the notice |
| Hextris | Puzzle | JavaScript, canvas | GPL-3.0 | Yes, if your game is GPL too |
| A Dark Room | Text adventure | JavaScript | MPL-2.0 | Yes, changed MPL files stay open |
| HexGL | 3D racing | JavaScript, Three.js (r53) | MIT | Yes, check per-file notices |
| shapez | Factory building | JavaScript | GPL-3.0 | Yes, if your game is GPL too |
| Antimatter Dimensions | Incremental | JavaScript, Vue | MIT | Yes, keep the notice |
| Radius Raid | Arena shooter | JavaScript, canvas | MIT | Yes, keep the notice |
| JavaScript Racer | Pseudo-3D racing | JavaScript, canvas | MIT | Yes, keep the notice |
| Ancient Beast | Turn-based strategy | TypeScript | AGPL-3.0 code, CC BY-SA 4.0 art | Yes, with source and share-alike |
| Freeciv-web | 4X strategy | JavaScript, WebGL, Java, C | AGPL (web client), GPL (server) | Yes, with source |
| OpenFront | Real-time strategy | TypeScript | AGPL-3.0 code, mixed assets | Code yes with source; some assets no |
| Lichess | Chess server | Scala, TypeScript | AGPL-3.0 | Yes, with source |
| CodeCombat | Coding RPG | JavaScript, CoffeeScript | MIT code, CC BY art | Code yes; levels aren't open source |
| Untrusted | Programming puzzle | JavaScript | CC BY-NC-SA 3.0 | No |
| Bitburner | Programming idle game | TypeScript | Apache 2.0 + Commons Clause | No selling |
Puzzle and casual games
2048 is the cleanest place to start. The code is short, split into small files (grid, tiles, input, rendering to the DOM) and MIT-licensed. It also handles touch swipes, so it's a good model for mobile input. Note that the game idea itself came from earlier games; the MIT licence covers this code, not the concept or anyone else's branding.
Hextris is a fast puzzle game drawn on a canvas, with touch input in its code. It's GPL-3.0, which is fine for learning and for open-source projects but rules it out as the base of a closed commercial game (more on that below).
A Dark Room shows how far a game can go with text and buttons. Its MPL-2.0 licence is a middle ground: you can combine it with your own closed code, but any changes you make to its files must stay open.
Racing and action games
HexGL is a futuristic 3D racer and one of the best-known early WebGL games. Its README says the code and resources are MIT unless a file says otherwise. It's built on Three.js r53 from 2012, so treat it as a study piece: the current Three.js API is very different, and our 3D HTML5 games guide covers the modern approach.
JavaScript Racer is Jake Gordon's step-by-step build of an outrun-style pseudo-3D racer in canvas, MIT-licensed, with articles explaining each stage. The same author's MIT-licensed tetris and breakout repositories make good companions.
Radius Raid is a polished shoot 'em up made for the js13kGames competition, where the whole zipped game must fit in 13 KB. It's MIT, but it was built for mouse and keyboard: we found no touch handlers in its code.
Strategy and simulation games
shapez is the rare commercial game whose full source is public: it sells on Steam and the source is GPL-3.0. The original repository is no longer actively maintained; development continues in the shapez Community Edition, also GPL-3.0.
Ancient Beast (TypeScript, AGPL-3.0 code with CC BY-SA 4.0 artwork and audio) and Freeciv-web (an HTML5 and WebGL version of the classic 4X game) are large, active strategy projects. OpenFront is a browser RTS in TypeScript whose licensing shows why you should read beyond the badge: the code is AGPL-3.0, assets in /resources are CC BY-SA 4.0, and assets in /proprietary are all rights reserved and can't be reused outside OpenFront.
Lichess is a full chess server rather than a single game, but its TypeScript front end is a good study of a fast, mobile-friendly game UI. It's AGPL-3.0: if you run a modified version as a public site, you must offer your players its source.
Games with strings attached
CodeCombat's code is MIT and its art and music CC BY, but the README states that the levels on its site are not open source. Untrusted is licensed CC BY-NC-SA 3.0, so it's free to modify for non-commercial use only. Bitburner uses Apache 2.0 with the Commons Clause, which removes the right to sell the software; that makes it "source-available" rather than open source in the usual sense.
One historical note: Mozilla's BrowserQuest (MPL 2.0 code, CC BY-SA 3.0 content) was an influential HTML5 multiplayer demo, but its repository is archived and marked deprecated.
Free HTML5 game templates and starter kits
A template gives you a working, empty project: a build setup, a scene, input and scaling. That's often more useful than a finished game, because there's nothing to strip out.
| Template | What you get | Licence |
|---|---|---|
| Phaser templates | Official Phaser 4 starters with Vite, in JavaScript or TypeScript, plus versions for React, Vue and other frameworks | MIT |
| LittleJS and LittleJS Arcade | A small 2D engine with a Vite starter, a breakout tutorial, puzzle and platformer examples, and over 50 arcade-style example games | MIT |
| MDN 2D breakout tutorial | A step-by-step canvas game in plain JavaScript | Code samples CC0 |
| phaser3-typescript | Many small game examples in TypeScript, written for Phaser 3 | MIT |
| Example .io game | A multiplayer browser game with Node.js, socket.io and canvas, with a written walkthrough | MIT |
| Our free HTML game code | Complete single-file games with tutorials, touch and keyboard input | MIT |
To start a Phaser project, run npm create @phaserjs/game@latest and pick a template; the CLI also offers three demo games. One detail worth knowing: the Phaser templates' build scripts include a log.js that sends Phaser Studio the template name, build type and Phaser version. The README documents it, and the dev-nolog and build-nolog scripts skip it.
MDN's licence file is unusually clear: code samples added on or after 20 August 2010 are in the public domain (CC0), while the prose is CC BY-SA 2.5. You can reuse the code freely; quoting the text needs attribution.
Free templates that work on mobile
"Works on mobile" is the thing free templates most often get wrong. Before you build on one, check that it:
- scales the canvas to any screen and handles both orientations (Phaser has a Scale Manager for this);
- reads touch or pointer events, not only the keyboard;
- stops the page from scrolling or zooming during play (
touch-action: noneon the canvas); - starts audio only after the first tap, as browsers require;
- stays small: compressed images and audio, and no unused libraries.
Our guide to HTML5 mobile game development covers each of these.
Collections and GitHub lists of open-source HTML5 games
When you want more than fifteen options, these lists are maintained and searchable:
- GitHub's html5-game topic listed more than 2,600 public repositories in October 2026. Sort by "Recently updated" to skip abandoned projects.
- awesome-open-source-games collects games of every kind whose source is on GitHub. The list itself is CC0.
- awesome-jsgames is a curated list of JavaScript games, also CC0, updated as recently as this month.
- js13kGames/games holds the production code of the games on the js13kGames website. Entrants publish their source, but each entry sets its own licence, so check before reusing anything.
- leereilly/games was for years the best-known list of games on GitHub. It's now archived (its last update was in September 2025), so some links may be stale.
A list licensed CC0 only means the list is free to copy. Every game in it keeps its own licence.
What free licences allow you to do commercially
This is the part to get right before you build on someone's code. The licence on a repository decides whether you can sell your game, whether you must publish your own source and whether you must credit the author.
| Licence | Sell a game built on it? | Must you share your source? | Credit required? |
|---|---|---|---|
| MIT, BSD, Apache-2.0 | Yes | No | Keep the copyright and licence notice |
| MPL-2.0 | Yes | Only for the MPL files you change | Keep the notices |
| GPL-3.0 | Yes | Yes, for the whole game, under the GPL | Keep the notices |
| AGPL-3.0 | Yes | Yes, even to players who only use it over the network | Keep the notices |
| CC0 / public domain | Yes | No | No |
| CC BY | Yes | No | Yes |
| CC BY-SA | Yes | Adaptations must use the same licence | Yes |
| CC BY-NC, BY-NC-SA | No | Varies | Yes |
| Commons Clause add-on | No selling | Depends on the base licence | Yes |
| No licence at all | No | Not applicable | Not applicable |
MIT and other permissive licences
Permissive licences let you use, change and sell the code, including inside a closed commercial game. The only firm duty is to keep the original copyright and licence text with the code. For a browser game, that usually means a LICENSE or third-party notices file in your build and the notice left in the source.
GPL and AGPL: copyleft
The GPL lets you sell a game, as the GNU GPL FAQ says plainly, but you must give everyone who gets the game the complete source under the same licence, and you can't add restrictions. A browser game sends its code to every player's browser, so the safe reading is that publishing a GPL web game counts as distributing it. The AGPL goes further: if you modify the code and people play it over a network, you must offer them your modified source.
In practice: GPL and AGPL code is excellent for learning, for open-source projects and for games you're happy to publish in full. It's the wrong base for a game you plan to license to a portal, sell to a client or keep closed.
Creative Commons: mostly for art, not code
Creative Commons licences are built for art, music and writing. Creative Commons itself recommends against using them for software (CC FAQ), but you'll still meet them on game assets and on some whole games. The licence list explains each element: BY means credit, SA means share-alike, NC means non-commercial only, ND means no changes. Any "NC" licence rules out ads, sales and client work.
No licence means no permission
A public repository without a licence isn't free to use. As Choose a License puts it, default copyright law applies, so the author keeps all rights. You can read the code and learn from it; you can't copy it into your game.
Code, art, names: three different questions
The licence on the code often doesn't cover everything in the repository:
- Assets frequently have their own terms: OpenFront's proprietary folder, Untrusted's non-commercial soundtrack, CodeCombat's closed levels.
- Names and logos are trademarks, which open-source licences don't grant. GDevelop's licence, for example, keeps the GDevelop name and logo as its author's property even though the engine is MIT.
- Clones of famous games may use free code but still copy protected names, characters or art. Rename and redraw anything that came from someone else's brand.
Free source code vs a commercial licence
Free code and paid code solve different problems. Here's the honest comparison with the games we sell:
| Typical open-source HTML5 game | Our commercial games | |
|---|---|---|
| Price | Free | One price per game and licence, paid once, no royalties (pricing) |
| Licence | MIT, GPL, AGPL, CC or none; varies per file | Standard or Extended commercial licence (draft terms, see licensing) |
| Can you keep your code closed? | Only with permissive licences | Yes |
| Tech | Anything from 2012 JavaScript to modern TypeScript | TypeScript, Phaser 4.2.1 or Three.js r186, Vite |
| Mobile | Often an afterthought | Touch, mouse, keyboard and gamepad in every game |
| Tests | Rare | Unit tests and Playwright end-to-end tests |
| Documentation | A README, if you're lucky | Quick start for install, build, test and deploy |
| Support | Community issues, if active | 12 months of updates and 6 months of integration support (Standard) |
| Can you redistribute the source? | Depends on the licence | No: you ship the game, not the source |
Our Standard licence covers one end product with one production web deployment, and allows reskinning, rebranding and monetising. The Extended licence covers up to 5 end products including client work, or up to 3 portal domains your company owns. Both are draft terms until legal review, and neither allows reselling or publicly uploading the source.
Each game ships as a buildable project: source, data files for tuning, tests, a README and third-party notices, checked in a clean-room build before it goes on sale. If you're comparing a free puzzle game with a finished one, look at these:
Liquid Lab
Pour layered liquids between tubes until each vessel contains a single formula or valid compound.
Arrow Grid Escape
Clear a board by launching directional arrow tiles without letting them collide or trap one another.
Gem Forge
Merge minerals into crystals, gemstones and magical artifacts that alter board behavior.
When free code is the better choice: you're learning, you're making a jam game, you're happy to open-source your game, or the game is small enough to write yourself. When a commercial licence is the better choice: you need a finished, tested game to reskin, license to a portal or deliver to a client this month, without copyleft obligations. Browse the full catalog, or start from the home page for licences and the FAQ.
How to download and run an open-source HTML5 game
- Check the licence first: open
LICENSEand the README, and look for separate asset terms. - Download it: on GitHub, use Code → Download ZIP, or clone it with
git clone. - Install and run: projects with a
package.jsonusually neednpm installand then a script such asnpm run dev(read the README for the exact command). - Serve static games over HTTP: games without a build step still need a local web server, because browsers block many file loads from a file opened straight from disk.
npx serveorpython -m http.serverin the game folder works. - Check its health: look at the date of the last commit, open issues and whether its dependencies install cleanly.
- Test on a phone before you commit to it.
For deploying the result, see how to host HTML5 games; for reshaping a game into your own, see how to customize an HTML5 game.
Learn from open source, then build your own
The fastest way to learn game programming is to read a small finished game, change it and break it. Start with 2048 or a single-file game from our code hub, move to an engine template, then study a larger project. Our guides cover the next steps: HTML5 canvas games, choosing an HTML5 game engine and making an HTML5 game from scratch. For background, start with what HTML5 games are, or browse every guide in Learn HTML5 game development.
Frequently asked questions
Is free HTML5 game source code safe to use in a commercial game?
It depends entirely on the licence. MIT, BSD, Apache-2.0 and CC0 code can go into a commercial, closed game if you keep the required notices. GPL and AGPL code can be sold but forces you to publish your game's source, and anything marked non-commercial, or with no licence at all, can't be used commercially.
Can I sell a game made from GPL code?
Yes, the GPL allows selling. But every buyer or player must be able to get the complete source of your game under the GPL, and they may share it freely. That suits open-source games, not games licensed exclusively to a portal or client.
What's the best open-source HTML5 game to learn from?
2048 for a small, readable codebase; JavaScript Racer for a guided, step-by-step build; and an official Phaser or LittleJS template once you want to work with an engine. For a large, modern TypeScript codebase, read OpenFront or Ancient Beast.
Where can I download HTML5 game source code for free?
From GitHub: the repositories in this guide, the html5-game topic and the curated lists above. Use Code → Download ZIP or git clone. Our free HTML game code pages also offer one-file games you can download directly.
Are there open-source HTML5 games for mobile?
Yes, but check each one. 2048 and Hextris include touch input in their code, and current engine templates support touch and screen scaling. Older canvas games were often built for mouse and keyboard only, so test on a phone before building on one.
Can I put an open-source HTML5 game on my website with ads?
With a permissive licence (MIT, BSD, Apache-2.0, CC0), yes, keeping the notices. With GPL or AGPL, yes, if you also offer the source. With any non-commercial licence or the Commons Clause, ads and sales are ruled out. Check the asset licences too, since art and music often have separate terms.
We make and sell HTML5 game source code; links to our games are marked as ours.


