Every football fan has picked an all-time XI in their head. Plenty of Sunday league managers still write their team sheet on the back of an envelope. I wanted a tool for both: pick a formation, drag players around a pitch, then download the lineup as an image or print it for the dressing room.
I built it as a free football formation creator that runs entirely in the browser: no framework, no backend, no sign-up. It's a single WordPress shortcode that outputs HTML, CSS and plain JavaScript. Here are the parts that were more interesting than I expected.
Turning "4-2-3-1" into positions on a pitch
Every formation is just a string. Split it on the dashes and you get the rows, from defence to attack:
const rows = f => f . split ( '-' ) . map ( Number ) ; // "4-2-3-1" -> [4, 2, 3, 1]
Enter fullscreen mode
Exit fullscreen mode
The goalkeeper always sits at the bottom.…