When you rebuild a site's look in Tailwind or a design system, colors and fonts are easy to read off the page. Spacing is harder. Nobody hands you "the scale"; you get hundreds of padding, margin and gap values, and you have to guess which ones are tokens and which are one-offs.
So I wrote a console snippet that counts what the page actually renders, and ran it on three fictional demo sites I built: Northwind Roasters (a coffee shop), Ledgerline (fintech) and Afterhours (a dark developer tool). Here's the snippet, the results, and the three things that made my first version wrong.
The snippet
function spacingScale ( ) { // Horizontal margins are left out: `margin: 0 auto` and flex `margin-left: auto` // compute to whatever space is left over, not to a spacing token. const props = [ 'padding-top' , 'padding-right' , 'padding-bottom' , 'padding-left' , 'margin-top' , 'margin-bottom' , 'row-gap' , 'column-gap' ] ; const counts = new Map ( ) ; for ( const el of document . body .…