Skip to content
OddsockLocal
Local
Size (px)
Grid step (px)

Nearest16

Down
8
Up
16
Nearest: 16Runs in this browser. Nothing is uploaded.

Ready

How to use

  1. Enter the size in pixels. Try 13.
  2. Enter the grid step. 8 is the usual base. 4 and 12 work too.
  3. Read Nearest, Down, and Up.
  4. Copy the value you will put in CSS.

What is 8px grid?

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.

Read more

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.

Use cases

  • A UI designer snapping a 13px icon gap to 16px before handing the frame to engineering.
  • A front-end developer turning a 21px Figma size into the 24px token the spacing scale actually has.
  • A design-system author checking a proposed type ramp against an 8px baseline.
  • A student learning why 13px and 21px feel off next to an 8px grid.
  • A reviewer comparing implemented padding with the spec during QA.
  • A brand designer working on a 4px grid for a compact settings screen.

Two sizes on an 8px grid

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.

Why use Oddsock

Oddsock runs this in your browser. It is free, it does not upload the work, and it does not ask for an account.

Related tools

Using this tool

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.