How to Add a Tic-Tac-Toe Game to Your Website
LK Forge · 4 min read · Updated August 2026
You can add a full, playable Tic-Tac-Toe game to any website, blog, or classroom page with a single line of code — free, with no sign-up, no plugin, and no script to install. Visitors play against a real AI opponent, and — unlike most tic-tac-toe embeds — this one ships with a provably unbeatable minimax engine they can test themselves. This guide covers the fastest way to embed the Unbeatable Tic-Tac-Toe AI, what makes it different, and where it works.
The quickest way: paste one embed snippet
An embed is just an <iframe> that loads the game from lkforge.com, plus a small credit line. Copy this into your page’s HTML where you want the game to appear:
<iframe src="https://lkforge.com/embed/tictactoe/"
width="100%" height="680" loading="lazy"
style="border:0;max-width:460px"
title="Unbeatable Tic-Tac-Toe AI by LK Forge"></iframe>
<p><a href="https://lkforge.com/games/tictactoe/">Unbeatable Tic-Tac-Toe AI</a>
by <a href="https://lkforge.com/">LK Forge</a></p> The <iframe> is the live game; the <p> underneath is a plain credit link. Keep that line — the visible link is what keeps the widget free to embed. You can also copy this exact code straight from the “Add This Tic-Tac-Toe AI to Your Website” section on the game page.
What makes this Tic-Tac-Toe different: a provably unbeatable AI
Most tic-tac-toe embeds ship a weak or random opponent. This one uses a real adversarial-search engine, which makes it a teaching tool as much as a game:
- Minimax + alpha-beta pruning — on 3×3 the Hard AI searches the complete game tree, so it is mathematically unbeatable: the best any player can force is a draw.
- Scales to bigger boards — from 4×4 up to 10×10 the search depth is capped, so a skilled player can set up a fork the AI can’t see far enough ahead to stop. Three difficulty levels (Easy, Medium, Hard) suit any audience.
That makes the embed a good fit for a puzzle blog, a computer-science or maths lesson on game-tree search, or any page where you want a game that also demonstrates how an AI decides. The engine is open source with a reproducible benchmark at github.com/lucian-devops/tictactoe-ai.
Where it works
Because it is a standard iframe, the embed works anywhere you can add HTML:
- WordPress: add a Custom HTML block and paste the snippet.
- Squarespace: use a Code / Embed block.
- Wix: add an Embed HTML / iframe element.
- Ghost: insert an HTML card.
- Notion: paste the
/embed/tictactoe/URL and choose "Create embed". - Plain HTML, an intranet, or a lesson page: paste the snippet straight into the markup.
The board is responsive — it fills the width you give the iframe up to a comfortable maximum — and cells are tap-friendly, so it is at home on phones as much as on desktop.
That’s the whole job. Copy the embed code from the Unbeatable Tic-Tac-Toe AI page and paste it wherever a puzzle blog, a games page, or a classroom activity needs an instant, self-contained game with a real AI opponent.
Grab the embed code from the 'Add This Tic-Tac-Toe AI to Your Website' section on the game page — free, no sign-up.
Open the Tic-Tac-Toe gameFrequently asked questions
- Is embedding the Tic-Tac-Toe game free?
- Yes. The game is free to embed on any site, with no account, no API key and no usage limits. It runs entirely in your visitor’s own browser, so there is no server cost — we only ask that you keep the small "Unbeatable Tic-Tac-Toe AI by LK Forge" credit line that comes with the embed code.
- Is the AI really unbeatable?
- On a classic 3×3 board, yes — Hard mode runs a full minimax search with alpha-beta pruning, so perfect play forces a draw and the AI never loses. On larger boards (4×4 up to 10×10) the search depth is capped for speed, which gives a sharp player a real chance to win. The engine is open source and the "0 losses across 1,270 games" figure is reproducible: run node benchmark.js from github.com/lucian-devops/tictactoe-ai.
- Does it work on phones and tablets?
- Yes. The board scales to the width you give the iframe and cells are tap-friendly, so it plays the same on touchscreens as with a mouse. Each visitor’s running score is saved locally on their own device.
- Where can I embed it — WordPress, Wix, Squarespace, Notion?
- Anywhere you can add HTML, because it is a standard iframe. In WordPress use a Custom HTML block; in Squarespace a Code/Embed block; in Wix an Embed HTML element; in Ghost an HTML card; in Notion paste the /embed/tictactoe/ URL as an embed. On a plain HTML page or an intranet, paste the snippet straight into the markup.
- Can I change the board size or difficulty?
- Yes. The embedded game includes the full setup screen: players pick a board size from 3×3 up to 10×10, choose their piece, and select Easy, Medium or Hard before playing. It is the same game as the full page, not a stripped-down version.
- Does the embedded game track visitors or set cookies?
- No. Everything runs locally in the visitor’s browser — no moves or scores are sent to a server. The embed sets no tracking cookies and sends no analytics, so it is safe to place on a privacy-sensitive site, an intranet, or a page for children.