Xerobit

Border Radius Generator: CSS Shorthand and Live Preview

This border radius generator produces the shortest valid CSS border-radius shorthand from per-corner horizontal and vertical radii. Set each corner independently in pixels or percentages, see an instant SVG preview, and copy the result. Everything runs in your browser with nothing uploaded.

Result

border-radius: 20px;
  • CSS
    border-radius: 20px;
  • Top-left
    20px / 20px
  • Top-right
    20px / 20px
  • Bottom-right
    20px / 20px
  • Bottom-left
    20px / 20px

How to use the css border radius generator

  1. Enter the horizontal and vertical radius for each of the four corners.
  2. Choose your preferred unit: px or %.
  3. The CSS shorthand updates instantly below the fields.
  4. Check the SVG preview to verify the shape visually.
  5. Copy the generated border-radius declaration into your stylesheet.

How the CSS border-radius shorthand works

The CSS border-radius property accepts up to eight values separated by a slash. The values before the slash set the horizontal radii; those after set the vertical radii. Both groups follow the clockwise order: top-left, top-right, bottom-right, bottom-left.

CSS allows you to omit trailing values when they match earlier ones. If all four horizontal radii are identical, you write just one number. If bottom-left equals top-right, you can drop it. The same logic applies to the vertical group. This border radius generator always outputs the shortest valid form.

For example, if every corner has a horizontal radius of 12px and a vertical radius of 12px, the full longhand would be border-radius: 12px 12px 12px 12px / 12px 12px 12px 12px;. Because all values match, the shorthand collapses to simply border-radius: 12px;.

Common border-radius patterns

Here is a reference table of frequently used shapes and their corresponding CSS declarations. You can reproduce any of these by entering the matching values into the fields above.

ShapeCSS valueNotes
Circleborder-radius: 50%;Element must be square
Pill / capsuleborder-radius: 9999px;Any large value works
Uniform roundborder-radius: 8px;All corners equal
Top onlyborder-radius: 12px 12px 0 0;Bottom corners stay square
Leafborder-radius: 40px 0 40px 0;Alternating corners
Ellipse cornersborder-radius: 20px / 40px;Horizontal differs from vertical

Pixels versus percentages

Choosing between px and % changes how the radius scales. Pixel values produce a fixed curve regardless of element size. A border-radius: 16px button looks the same whether it is 100px wide or 400px wide.

Percentage values are relative to the element's own dimensions. A horizontal percentage refers to the element's width, and a vertical percentage refers to its height. Setting border-radius: 50% on a square element creates a perfect circle, but on a rectangle it creates an ellipse. Use percentages when you want the curvature to scale proportionally with the container, such as in responsive layouts built with tools like the CSS grid generator or flexbox generator.

Using this border-radius CSS generator in practice

A dedicated border-radius CSS generator saves time because writing the slash syntax by hand is error-prone. Developers often forget that the order is top-left, top-right, bottom-right, bottom-left, or they misplace the slash. This tool handles the ordering and the shorthand reduction automatically.

The SVG preview renders the exact path your CSS will produce. When you adjust a single corner, you immediately see whether the curve overlaps or leaves a gap. For complex UI components like chat bubbles, cards with mixed corners, or custom toggle switches, visual feedback prevents trial-and-error in the browser dev tools.

If you need to convert the resulting pixel values to relative units later, pair this tool with the px to rem converter or the em to px converter.

Edge cases and browser behavior

When adjacent corner radii are so large that they overlap, browsers proportionally reduce them to fit. The CSS specification defines this algorithm: the ratio of each radius to the sum of the two adjacent radii along the same edge determines the scaling factor. You do not need to calculate this yourself, but it means setting every corner to 9999px safely produces a pill shape rather than breaking the layout.

Negative values are invalid in CSS. This tool rejects them before generating output. Zero values are valid and produce a sharp corner. When all eight values are zero, the generator outputs border-radius: 0;, which is useful for resetting inherited styles.

Worked examples

ExampleInputResult
Uniform circleTop-left horizontal: 50; Top-left vertical: 50; Top-right horizontal: 50; Top-right vertical: 50; Bottom-right horizontal: 50; Bottom-right vertical: 50; Bottom-left horizontal: 50; Bottom-left vertical: 50; Unit: %; Preview background: whiteCSS: border-radius: 50%;; Top-left: 50% / 50%; Top-right: 50% / 50%; Bottom-right: 50% / 50%; Bottom-left: 50% / 50%
Pill shapeTop-left horizontal: 999; Top-left vertical: 999; Top-right horizontal: 999; Top-right vertical: 999; Bottom-right horizontal: 999; Bottom-right vertical: 999; Bottom-left horizontal: 999; Bottom-left vertical: 999; Unit: px; Preview background: whiteCSS: border-radius: 999px;; Top-left: 999px / 999px; Top-right: 999px / 999px; Bottom-right: 999px / 999px; Bottom-left: 999px / 999px
Leaf (asymmetric)Top-left horizontal: 40; Top-left vertical: 0; Top-right horizontal: 0; Top-right vertical: 40; Bottom-right horizontal: 40; Bottom-right vertical: 0; Bottom-left horizontal: 0; Bottom-left vertical: 40; Unit: px; Preview background: whiteCSS: border-radius: 40px 0px / 0px 40px;; Top-left: 40px / 0px; Top-right: 0px / 40px; Bottom-right: 40px / 0px; Bottom-left: 0px / 40px
Only top corners roundedTop-left horizontal: 16; Top-left vertical: 16; Top-right horizontal: 16; Top-right vertical: 16; Bottom-right horizontal: 0; Bottom-right vertical: 0; Bottom-left horizontal: 0; Bottom-left vertical: 0; Unit: px; Preview background: whiteCSS: border-radius: 16px 16px 0px 0px;; Top-left: 16px / 16px; Top-right: 16px / 16px; Bottom-right: 0px / 0px; Bottom-left: 0px / 0px

FAQ

What does the slash mean in border-radius?

The slash separates horizontal radii from vertical radii. Values before the slash control the width of the curve at each corner, and values after control the height. This lets you create elliptical corners instead of circular ones.

How do I make a perfect circle with CSS?

Set the element to equal width and height, then apply border-radius: 50%;. Using 50% ensures the curve scales correctly even if you change the element's size later.

Can I round only specific corners?

Yes. Provide values for all four positions in clockwise order (top-left, top-right, bottom-right, bottom-left) and set the ones you want sharp to 0. For example, border-radius: 10px 0 0 10px; rounds only the left side.

Is this border radius generator free to use?

Yes. It runs entirely in your browser. No data is sent to any server, and there are no usage limits.

Why does my border-radius look different on a rectangle?

If you use percentage values, the horizontal radius is a percentage of the element's width and the vertical radius is a percentage of its height. On a non-square rectangle, this produces an ellipse. Switch to pixel values for uniform curves.

What is the maximum border-radius value?

CSS does not enforce a hard maximum, but extremely large values like 9999px are commonly used to create pill shapes. Browsers automatically scale overlapping radii down so the curves never exceed the element's edges.