IKEA Lillabo wooden train setAs a child I always wanted a toy train.
I used to leaf through the LIMA catalogues (the company was later absorbed by Hornby) with great passion.
And who would have thought that, many years later, trains would become so familiar to me through my work…

So I bought my little boy the IKEA Lillabo train.

All wood (of course). Twenty pieces to combine freely (or almost).

Update, November 2026: this post started in 2011 as a dad’s curiosity. I’m coming back to it fifteen years later to collect everything you can do with the Lillabo as a developer or analyst: algorithms, how the number of layouts grows, compatibility, 3D printing, electronics. The original IKEA links in the post are gone, so I removed them.

John Graham-Cumming’s program (2010)

Luckily John Graham-Cumming decided to write a small but remarkable program that computes the possible combinations: that is, the closed circuits you can build using all the available pieces.
Not a trivial thing, since besides curves there are straights and a large bridge.

Update, November 2026: a technical correction I got wrong in 2011. The computation is written in Perl; Processing only draws the circuits (the drawing code is linked in the comments of his post). John’s code is released under the GPL v2.

His program, needless to say, works with any number of components: John reports 9 circuits for the basic set, 18 with two extra curves and 130 with four extra curves. For the basic set of the time (12 curves, 2 straights, a two-part bridge treated as a single piece, plus 4 pieces for the train itself) the nine circuits suggested by the software are more than enough to keep my son entertained! And, above all, his dad.

Nine closed track layouts built with the 12 curves, 2 straights and 1 bridge of the basic Lillabo set, one of them a figure eight
The nine circuits of the basic set, recomputed and redrawn by me in 2026 (blue: straights, red: bridge). Number 4 is a figure eight: the bridge goes over the straight.

What changed in the box

The current basic set still has 20 pieces, but IKEA describes it as having solid beech track, an ABS plastic tunnel and wagons that connect with magnets. I have not verified how many pieces of each type the current track contains: all the numbers below apply to the 2010 composition described by John (12 curves, 2 straights, 1 bridge) and to the variants I add myself. IKEA also sells separate track packs (the 10-piece “Lillabo Rail”) and a 50-piece set: with those the combinatorial problem changes size.

The algorithms, explained

To understand what John’s program does, and why the numbers explode, I rewrote the solver from scratch (Python, without looking at his code) and compared it with his results. The model is the same abstract one he uses:

  • Unit of length = one straight. The bridge is a straight of length 2.
  • The curve is a 45° arc of radius 1 (the chord is 2·sin 22.5° ≈ 0.765). It can be clockwise (C) or anticlockwise (A): the same piece, rotated.
  • The laying state is a triple (x, y, heading), with the heading in multiples of 22.5°.
  • A circuit is valid if, after laying all the pieces, you are back at the origin with the same heading.

The search is a depth-first search (DFS): at each step it tries a straight, a bridge, a clockwise curve or an anticlockwise curve. Without pruning there would be about 4n cases; two checks make it practical:

  1. Distance from the origin: if the distance from the origin exceeds the length of the pieces still to lay, the branch is dead (triangle inequality).
  2. Remaining rotation: with r curves still available, the net rotation you can reach is −r, −r+2, … , +r (in 45° steps). If the missing heading is not among these values (mod 360°), the branch is dead.

The second check carries the most weight: closure strongly constrains how many curves can be clockwise and how many anticlockwise, so the search mostly explores where to put the straights and the bridge.

Deduplication is the step that is easiest to get wrong. A circuit is a cyclic word over {C, A, S, B}, and the same physical track generates many of them: you can start from any piece (rotation), look at it in a mirror (swap C↔A) or run it backwards (reverse the word and swap C↔A). The representative is the lexicographically smallest word among all the variants:

def canonical(s):
    mirror  = s.translate(str.maketrans("CA", "AC"))
    reverse = s[::-1].translate(str.maketrans("CA", "AC"))
    variants = []
    for base in (s, mirror, reverse, reverse.translate(str.maketrans("CA", "AC"))):
        variants += [base[i:] + base[:i] for i in range(len(base))]
    return min(variants)

def circuits(curves, straights, bridges, EPS=1e-9):
    CH = 2 * sin(radians(22.5))                       # chord of the curve
    COS = [cos(radians(22.5 * k)) for k in range(16)]
    SIN = [sin(radians(22.5 * k)) for k in range(16)]
    found = set()

    def search(x, y, h, seq, c, s, b, rest):
        if x*x + y*y > (rest + EPS) ** 2:              # pruning 1: distance
            return
        if not rotation_possible(c, (-(h // 2)) % 8):  # pruning 2: rotation
            return
        if c + s + b == 0:
            if abs(x) < 1e-7 and abs(y) < 1e-7 and h % 16 == 0:
                found.add(canonical("".join(seq)))
            return
        if s:                                          # straight (length 1)
            search(x + COS[h], y + SIN[h], h, seq + ["S"], c, s - 1, b, rest - 1)
        if b:                                          # bridge (length 2)
            search(x + 2*COS[h], y + 2*SIN[h], h, seq + ["B"], c, s, b - 1, rest - 2)
        if c:                                          # curve: C = clockwise, A = anticlockwise
            for sym, d in (("C", -1), ("A", 1)):
                m = (h + d) % 16                       # chord direction
                search(x + CH*COS[m], y + CH*SIN[m], (h + 2*d) % 16,
                       seq + [sym], c - 1, s, b, rest - CH)
    ...

(rotation_possible(c, need) checks whether some k in {−c, −c+2, …, c} satisfies k ≡ need mod 8.) The full code also includes the drawing function and the overlap check; here I only show the core.

Why I find 10 sequences and 9 circuits

With 12 curves, 2 straights and 1 bridge the solver returns 10 distinct canonical words. Two of them describe the same geometric shape: a run of length 2 can be the bridge or the two straights laid one after the other (SSB versus BSS in equivalent positions). Adding up the runs of straights and comparing shapes, the circuits become 9: the same number as John, who in fact states that he swaps the straights around the bridge when removing duplicates.

What about overlaps?

John's algorithm does not check whether the track crosses itself: it counts closures. I added a physical check, very simplified: I sample the centreline of every piece and verify that two non-adjacent pieces never come closer than one track width w = 0.28 (in units of the straight), allowing contact only under the free central span of the bridge. The width is my assumption: the results are almost insensitive to w. With 14 curves I get 15 circuits with both w = 0.15 and w = 0.36; with 16 curves the count goes from 107 to 103 as w grows. But such a simple geometric check is no substitute for a physical one: the play in the joints (the "Vario system" I mention below) allows circuits that the model rejects.

How fast the combinations grow

I ran the solver changing one piece at a time. The columns count the distinct geometric shapes and, among them, those without illegal overlaps. Timings: Python on a single core, from fractions of a second (basic set) to 89 seconds (16 curves, 6 straights).

Curves Straights Bridges Distinct shapes Without overlaps
12 2 1 9 9
14 2 1 18 15
16 2 1 122 103
18 2 1 354 248
20 2 1 1,858 1,283
12 4 1 59 58
12 6 1 242 238
12 8 1 687 675
16 4 1 1,539 1,315
16 6 1 10,712 9,125
12 2 2 47 44
12 2 3 71 67

Bar charts on a log scale showing how the number of distinct closed layouts grows when adding curves, straights or bridges

What the data says, in three points:

  • Curves make the numbers explode, in steps: 9 → 18 → 122 → 354 → 1,858 as pairs of curves are added (206 times in four steps, about ×3.8 per step). The ratio alternates ×2, ×6.8, ×2.9, ×5.2: there is a regularity (the steps from 12 to 16 and from 16 to 20 are worth about ×14 and ×15, the one from 14 to 18 about ×20), but I do not have a complete explanation. One extra pair of curves (12 to 14) doubles the count, while four extra multiply it by 14.
  • Straights grow more slowly, but they are the "cheapest" pieces. For a fixed number of curves the straights have to be distributed in the gaps between pieces: growth is polynomial and the ratio falls (×6.6, ×4.1, ×2.8 with 12 curves). Two extra straights give 59 circuits, against 18 for two extra curves.
  • A second bridge is worth less than two straights: same length, but 47 shapes against 59, because the bridge is indivisible. Its value lies elsewhere: it is the only piece that allows crossings (the figure eight in the chart above). A third bridge adds very little (71 shapes).

The share of circuits that survive the overlap check falls as curves are added: 100% with 12, 83% with 14, 84% with 16, 70% with 18, 69% with 20. The longer the circuit, the more likely it touches itself (and the more you need a table rather than the nursery floor).

An honest comparison with John: my 9 and my 18 match his. With four extra curves I find 122 shapes (103 without overlaps) against his 130, and I have not explained the difference: I did not run his code and the deduplication rules are not identical (he, for example, restricts the curve sequences so that they end with an anticlockwise curve). Other counts out there match neither of us: a model-railway blog reports 16 unique solutions from a basic set, computed by another author with rules and a piece list I do not know. The number depends on the rules: when you read "N circuits", always ask what counts as the same.

Further reading and code

Compatibility: Lillabo, Brio and the others

On paper the system is universal: in the world of wooden trains gauge and joints follow a de facto standard. IKEA claims the Lillabo can be combined with most other systems. In practice the reviews disagree: for some customers the Lillabo pegs and holes are slightly smaller and do not connect to Brio, for others everything fits. The same reviewer notes that those tracks have the groove on one side only, so you cannot flip them.

If you own both Lillabo and Brio, printed adapters are the simplest solution: Toy2 connectors join Brio track and Duplo bricks and, according to that review, also work with IKEA and Eichhorn track. They are also a good starting point for the 3D-printed models below.

3D printing: the community's most appreciated solutions on MakerWorld

MakerWorld now hosts a small industry of compatible tracks, switches, bridges and locomotives. I collected the most appreciated models: the data is from 28 November 2026 (likes, downloads, prints) and changes every day.

Model Author Likes Downloads Prints Licence
Starter Set - KYZ Train Tracks KYZ Design 5,078 9,184 5,545 MakerWorld Exclusive
Brio Train Track Replicas Cactus 973 3,437 12,468 9,977 CC BY-NC-SA
Tiny Train, Ikea Brio/Lillabo alternative One Maker Show 3,078 5,409 3,355 Standard Digital File
Train Tracks compatible with Brio/Ikea (Flex) TerTerro 2,930 14,010 11,798 Standard Digital File
Geared Train Track Switch (Brio, IKEA, Hape…) dialed in 2,795 7,402 6,057 Standard Digital File
Collapsing Bridge, Brio compatible paillardf 2,294 2,997 2,234 CC BY-NC-SA
Train Tunnel with overpass for BRIO/IKEA/LILABO hubi 2,248 7,243 5,788 Standard Digital File
Spiral bridge track for IKEA Lillabo and Brio GENERA 3D MODEL ART 1,433 3,232 2,036 Standard Digital File
IKEA LILLABO BRIO Full Set 90° Bridge Ramps M.verbeke 1,408 4,294 2,371 CC BY-NC-SA
Brio Track Customizer w/ STLs (58 track shapes) CavemanDesigns 1,089 1,980 760 Standard Digital File
BRILO, hybrid brick for BRIO and DUPLO JayDK 1,023 6,304 5,493 CC BY-NC-SA
Motorization kit for your tiny train Kevin3D 527 629 310 Standard Digital File
Parametric Train Track Generator (OpenSCAD) SalvaMX 64 88 27 Standard Digital File

Notes to read before you print:

  • Check compatibility before printing in bulk: some models are explicitly for Brio and the Lillabo has different tolerances (see above). Cactus 973's replicas are designed for Brio, not for the Lillabo.
  • Licences are not all the same: CC BY-NC-SA models allow non-commercial modification and sharing under the stated conditions; for "MakerWorld Exclusive" and "Standard Digital File" read the licence before modifying or sharing. I do not republish or redistribute anything: the links go to the original pages.
  • For developers, two models are "code": CavemanDesigns' Customizer (58 track shapes) and the parametric OpenSCAD generator, which lets you redo the pieces with the right tolerance for your own Lillabo.
  • Models I saw but left out of the table: the 360° turntable/switch, CUBEUNi's washing-machine train and kyle_k's castle drawbridge.

Electronics: motorising and connecting the train

The IKEA battery locomotive runs on two AAA cells (IKEA recommends two 750 mAh LADDA rechargeables), and for many uses it is already enough. For a maker project there are three typical routes. The examples below are not all about the Lillabo, but the scheme carries over almost unchanged to any toy locomotive with a DC motor:

  • Remote on/off with a MOSFET: Zoltan Balazs put an IRL540 MOSFET between the battery and the motor of a toy train and drove it with an ESP32-C3, connecting it to Home Assistant through Matter (project write-up, Hackaday summary). It switches on and off, but you cannot regulate the speed.
  • Speed and direction control with an H-bridge: in this LEGO project an ESP32 drives the motor through a DRV8833, powered by a lithium battery with DC-DC converters and controlled from a phone over Bluetooth.
  • A new, printed locomotive: a project for wooden track uses a 3D-printed chassis, a geared motor on one axle, an ESP32 with a driver and an 18650 cell. The author says the hard part is balancing traction: enough to climb bridges, not so much that the engine climbs out of the rail. Another project uses an Arduino Nano with an ESP8266 Wi-Fi module on a battery-powered toy train (olisto/iotrain).

Block diagram of a motorised wooden-train locomotive: battery, 3.3 V regulator, ESP32, DRV8833 motor driver, Hall sensor and LEDs
A schematic I drew as a synthesis of the projects above. It is a design idea, not a circuit I have built or tested.

Two ideas for going further, both untested: the Lillabo wagons are coupled by magnets, and a Hall or reed sensor on the track could count passes to reconstruct the position (the magnet-plus-Hall-sensor technique for absolute position is used in an ESP32 roller-coaster model). The same ESP32 can then publish its state over MQTT or Home Assistant and close the loop with the solver: a circuit chosen by the algorithm, a train that runs it.

Safety warning. A modified toy is no longer the certified one (IKEA's CE marking covers the original product). Lithium cells and neodymium magnets must never be accessible to small children: they are dangerous if swallowed. Close the battery compartment securely, protect the cell (protection circuit, fuse) and use the modified train only under supervision and away from the youngest.

What to buy

The Lillabo is sold by IKEA. For everything else, here is what looks useful to me:

Compatible toys and track

Books for the analyst

Parts for the electronics

As an Amazon Associate I earn from qualifying purchases. Some links (Amazon and AliExpress) are affiliate links: they cost you nothing and help keep this blog running.