What it is
A small Christmas scene drawn with code: a tree built from little cubes that keeps turning through 360 degrees, with twinkling lights, falling snow, gift boxes, gingerbread cookies, candy canes, a snowman, and a sleigh with reindeer that crosses the sky every 22 seconds. You can drag it to spin it by hand. It is one HTML file with no libraries and no server, so it works anywhere a web page works.
How to take it
Pick whichever way suits you. All three give you the same thing.
1. Download the file
Press Download the HTML file above. You get pixel-christmas-tree.html. Double-click it to open it in your browser, or upload it to your own site. It also works offline.
2. Copy the code
Press Copy the code, paste it into a new file, and save it with a name that ends in .html. This is handy for online editors such as CodePen or for pasting into a project.
View the code
Loading…3. Embed it on your page
Paste this where you want the tree to appear. It loads the tree from this site, so you do not need to host anything.
<iframe src="https://aspect.tools/pixel-tree" width="420" height="720" style="border:0;max-width:100%" title="Pixel Christmas tree" loading="lazy"></iframe>
License and credit
A visible credit is not required, but it is appreciated. If you want to give one, use:
Pixel Christmas Tree, 2026 series, by aspect.tools (https://aspect.tools/christmas), MIT License
The file comes with no warranty. The small credit line under the tree can be removed if you keep the notice inside the file.
How to change it
Open the file in any text editor. The settings are plain numbers near the top of the script:
| What to change | Where | Example |
|---|---|---|
| Tree height and width | TH and RM | TH = 62, RM = 21 |
| Gift boxes | the gift(...) lines: angle, distance, width, height, depth, box colour, ribbon colour | gift(0.3, 27, 9, 6, 9, P.red, P.gold) |
| Cookies and candy canes | the plant(...) lines: picture, colours, angle, distance | plant(COOKIE, COOKIE_C, 0.78, 36, 2) |
| How often the sleigh flies | GAP (seconds between flights) and FLY (seconds to cross) | FLY = 8, GAP = 22 |
| Starting speed | the value of the speed slider | value="35" |
| Amount of snow | the number in the snowflake loop | s < 170 |
The cookie and candy cane are drawn as small text pictures (the COOKIE and CANE lists), so you can draw your own figure by typing letters in a grid.
How it works
Every cube has a position in 3D. On each frame the page turns all positions around the vertical axis, flattens them onto the screen, and writes them into a 240 × 270 pixel picture, keeping the nearest cube for each pixel. The picture is then scaled up without smoothing, which gives the chunky pixel look. Because the picture is so small, it runs smoothly on phones.
Questions
Can I use the pixel Christmas tree on my own website?
Yes. It is under the MIT License, so personal and commercial use are both allowed. Keep the license notice inside the file.
Do I have to give credit?
You must keep the copyright and license notice in the file. A visible credit or a link back is appreciated but not required.
Does it need a server or any libraries?
No. It is a single HTML file that runs in the browser and also works offline.
Does it work on phones?
Yes. It fits the screen width, and you can drag with a finger to spin the tree.
Can I change the colours or add my own decorations?
Yes. Open the file in a text editor. The gifts, cookies and timing are set by short lines near the top of the script.