Test store. Prices are the planned list prices stored as test data, license terms are drafts, and payments go to a Stripe test-mode account. No real money moves.

Free and Open-Source HTML5 Games with Source Code: Games, Templates and Licences

The best free HTML5 game source code is on GitHub: complete open-source games such as 2048 (MIT), Hextris (GPL-3.0) and A Dark Room (MPL-2.0), free starter templates from Phaser and LittleJS, and curated lists. Free doesn't mean unrestricted: MIT allows commercial reuse with a notice, GPL and AGPL make you share your source, and non-commercial licences forbid selling.

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 toBest sourceTypical licence
Learn how a game worksShort single-file games and tutorialsMIT, CC0
Study a real, finished gameOpen-source games on GitHub (list below)MIT, GPL, MPL, AGPL
Start a new project fastOfficial engine templatesMIT
Browse many optionsCurated "awesome" lists and GitHub topicsVaries per game
Ship a commercial game quicklyA finished game with a commercial licenceCommercial

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.

GameGenreMain techLicenceCommercial reuse
2048Sliding puzzleJavaScriptMITYes, keep the notice
HextrisPuzzleJavaScript, canvasGPL-3.0Yes, if your game is GPL too
A Dark RoomText adventureJavaScriptMPL-2.0Yes, changed MPL files stay open
HexGL3D racingJavaScript, Three.js (r53)MITYes, check per-file notices
shapezFactory buildingJavaScriptGPL-3.0Yes, if your game is GPL too
Antimatter DimensionsIncrementalJavaScript, VueMITYes, keep the notice
Radius RaidArena shooterJavaScript, canvasMITYes, keep the notice
JavaScript RacerPseudo-3D racingJavaScript, canvasMITYes, keep the notice
Ancient BeastTurn-based strategyTypeScriptAGPL-3.0 code, CC BY-SA 4.0 artYes, with source and share-alike
Freeciv-web4X strategyJavaScript, WebGL, Java, CAGPL (web client), GPL (server)Yes, with source
OpenFrontReal-time strategyTypeScriptAGPL-3.0 code, mixed assetsCode yes with source; some assets no
LichessChess serverScala, TypeScriptAGPL-3.0Yes, with source
CodeCombatCoding RPGJavaScript, CoffeeScriptMIT code, CC BY artCode yes; levels aren't open source
UntrustedProgramming puzzleJavaScriptCC BY-NC-SA 3.0No
BitburnerProgramming idle gameTypeScriptApache 2.0 + Commons ClauseNo 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.

TemplateWhat you getLicence
Phaser templatesOfficial Phaser 4 starters with Vite, in JavaScript or TypeScript, plus versions for React, Vue and other frameworksMIT
LittleJS and LittleJS ArcadeA small 2D engine with a Vite starter, a breakout tutorial, puzzle and platformer examples, and over 50 arcade-style example gamesMIT
MDN 2D breakout tutorialA step-by-step canvas game in plain JavaScriptCode samples CC0
phaser3-typescriptMany small game examples in TypeScript, written for Phaser 3MIT
Example .io gameA multiplayer browser game with Node.js, socket.io and canvas, with a written walkthroughMIT
Our free HTML game codeComplete single-file games with tutorials, touch and keyboard inputMIT

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: none on 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.

LicenceSell a game built on it?Must you share your source?Credit required?
MIT, BSD, Apache-2.0YesNoKeep the copyright and licence notice
MPL-2.0YesOnly for the MPL files you changeKeep the notices
GPL-3.0YesYes, for the whole game, under the GPLKeep the notices
AGPL-3.0YesYes, even to players who only use it over the networkKeep the notices
CC0 / public domainYesNoNo
CC BYYesNoYes
CC BY-SAYesAdaptations must use the same licenceYes
CC BY-NC, BY-NC-SANoVariesYes
Commons Clause add-onNo sellingDepends on the base licenceYes
No licence at allNoNot applicableNot 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 gameOur commercial games
PriceFreeOne price per game and licence, paid once, no royalties (pricing)
LicenceMIT, GPL, AGPL, CC or none; varies per fileStandard or Extended commercial licence (draft terms, see licensing)
Can you keep your code closed?Only with permissive licencesYes
TechAnything from 2012 JavaScript to modern TypeScriptTypeScript, Phaser 4.2.1 or Three.js r186, Vite
MobileOften an afterthoughtTouch, mouse, keyboard and gamepad in every game
TestsRareUnit tests and Playwright end-to-end tests
DocumentationA README, if you're luckyQuick start for install, build, test and deploy
SupportCommunity issues, if active12 months of updates and 6 months of integration support (Standard)
Can you redistribute the source?Depends on the licenceNo: 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:

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

  1. Check the licence first: open LICENSE and the README, and look for separate asset terms.
  2. Download it: on GitHub, use Code → Download ZIP, or clone it with git clone.
  3. Install and run: projects with a package.json usually need npm install and then a script such as npm run dev (read the README for the exact command).
  4. 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 serve or python -m http.server in the game folder works.
  5. Check its health: look at the date of the last commit, open issues and whether its dependencies install cleanly.
  6. 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.