Inputs
Nearest16
Ready
An 8px grid is a promise that spacing, type, and icons land on the same rhythm. A 13px gap next to a 16px button looks slightly drunk, and it gets worse when the layout is checked at 2x. This calculator takes a pixel size and a step, then tells you the multiple you should actually ship.
The step is not locked to 8. A dense mobile UI often uses 4. A poster layout might use 12. You type the size you were given, usually from a mock that was drawn by eye, and the page returns three numbers: the nearest multiple, the one below, and the one above. Nothing is rewritten in your CSS. You copy the number you want.
Rounding half-steps is where people argue. 12px on an 8px grid is already on the grid. 13px is closer to 16 than to 8, so nearest is 16, down is 8, and up is 16. 21px is closer to 24. If a design system says “always round down,” use Down and ignore Nearest.
Size 13px, grid 8px. Then size 21px, grid 8px.
13 becomes nearest 16, down 8, up 16. 21 becomes nearest 24, down 16, up 24.
Oddsock runs this in your browser. It is free, it does not upload the work, and it does not ask for an account.
Nearest is the multiple of the grid step closest to the size you typed. 13 on an 8px grid is 16, because 13 is 3 away from 16 and 5 away from 8.
Yes. Grid step is any positive number. Set it to 4 for a half-grid, or 10 if the layout is on a 10px baseline.
21 divided by 8 is 2.625. The nearest multiple is 24, and it is easy to write 20 when you are moving fast.
No. It only shows the numbers. You copy the one you want into padding, gap, or a token.
Nearest, down, and up are the same number. 16 on an 8px grid stays 16.