Colour CSS

Border radius generator

Generated in your browser · nothing is uploaded

Live preview · collapses to the shortest form

Sets each corner radius independently and writes the shortest shorthand that means it: four equal corners collapse to one value, a diagonal pair to two, and so on.

How to use the border radius generator

1 Drag the radius with all corners linked, or untick that to set each corner on its own.
2 Switch the unit between px, rem and per cent. Percentages behave quite differently from the other two.
3 Watch the shorthand collapse as corners come into agreement.
4 Copy the shortest form, which is what you would have written by hand.

The shorthand runs clockwise from the top left, so top-left, top-right, bottom-right, bottom-left, and it fills in missing values the way margin does. One value applies to all four corners. Two values set the two diagonals, the first for top-left and bottom-right and the second for the other pair. Three values give top-left, then the top-right and bottom-left pair, then bottom-right. That last case is the one people misread: border-radius: 8px 2px 0px means an 8px top-left corner, 2px on both of the other diagonal corners, and a square bottom-right. Watching the value here collapse as you move the sliders is a quicker way to learn the rule than reading it.

Percentages behave differently from pixels in a way that surprises almost everyone the first time. A percentage radius resolves against the element’s own width and height separately, so on a rectangle the corner it draws is elliptical rather than circular. border-radius: 50% on a square gives a circle; on a 200 × 100 box it gives an oval. That is deliberate, and it is how an ellipse gets drawn in CSS with no SVG involved. It also explains why a percentage radius that looked right on one card looks wrong on a wider one, and why fixed units are the safer default for anything that has to look consistent across differently shaped elements.

The pill trick works because of a clamping rule rather than a special case. Ask for a 999px radius on a 40px-tall button and the browser does not simply refuse: the specification says that when the radii along any edge add up to more than that edge’s length, every radius on the box is scaled down by one common factor, the smallest ratio needed to make them all fit. So a huge value collapses proportionally to exactly half the shorter dimension, giving a perfect pill on any height without you knowing the height. That same rule is what stops a large radius from overlapping itself on a small box. Behind all of this the browser is really storing two radii per corner, one horizontal and one vertical, which is the slash form: border-radius: 20px / 40px, or the full a b c d / e f g h. This generator emits the single-radius form, so genuinely elliptical corners are something to write by hand.

What people use it for

  • Working out which corner a value in an existing shorthand applies to
  • Rounding the top two corners of a sheet or a tab and leaving the rest square
  • Drawing an ellipse in CSS without reaching for SVG
  • Getting a pill shape on a button whose height you do not control
  • Collapsing four corner values to the shortest form that still means them
  • Checking a radius reads correctly in rem when the page is zoomed

Questions

Clockwise from the top left: top-left, top-right, bottom-right, bottom-left, with the same fill-in rules as margin.

MDN, border-radius
Was this tool any good?
Internal signal only · I use it to find the tools worth rebuilding