CSS Border Radius Generator

Introduction

Rounded corners are one of those details that quietly shape how an interface feels. A square card with sharp corners can look rigid, technical, or severe, while the same card with a modest curve often feels softer, friendlier, and more modern. That visual shift is usually controlled with one CSS property: border-radius. This generator is designed to make that property easy to understand in practice. You enter the corner values, the preview updates immediately, and the tool writes the CSS declaration for you in the same clockwise order that browsers expect.

The calculator on this page focuses on a very common workflow: setting the top-left, top-right, bottom-right, and bottom-left corner radii in pixels. Sometimes you want a perfectly even button radius, so all four corners should match. Sometimes you want an uneven, intentionally asymmetrical shape for a badge, callout, tag, or speech bubble. The live preview lets you compare those ideas quickly without guessing from raw code alone. That matters because corner curvature is a visual judgment as much as a numerical one.

Even though the interface is simple, the concept behind it is surprisingly rich. CSS can round corners with circles, with ellipses, with percentages, and with shorthand patterns that reuse values in different positions. Once you understand how those values map onto the box, you can build cards, pills, chips, avatars, mobile-style controls, and playful organic shapes directly in code. In other words, this is not just a tiny utility for one property. It is a quick training ground for learning how a rectangle turns into a designed component.

How to Use

Start by typing a number into any of the four fields: Top Left, Top Right, Bottom Right, and Bottom Left. The current tool outputs pixel values, so entering 12 means 12px. With the Link radii checkbox turned on, any change you make to one field is mirrored across all four corners. That is the fastest way to test uniform rounding for buttons, cards, or avatars. If you uncheck the box, each corner becomes independent and you can shape the rectangle one corner at a time.

As you edit the numbers, the preview box updates instantly. The code area below the preview shows the exact CSS declaration generated from your inputs. The order is always clockwise: top-left, top-right, bottom-right, bottom-left. For example, entering 8, 16, 24, and 32 produces border-radius: 8px 16px 24px 32px;. That output is ready to paste into a stylesheet, component file, inline style object, or design token reference.

A good way to learn is to try a few intentional patterns instead of random values. Set every corner to 0 to see a sharp rectangle. Then try 12 on all four corners for a soft card. Next, set opposite corners to the same value, such as 40 8 40 8, and notice how quickly the shape gains character. Finally, push all four corners to a large value relative to the box size to see the shape approach a pill. Those experiments build intuition faster than memorizing syntax alone.

If you are using the generator during design work, it helps to think about the job the component needs to do. Small radii often feel clean and efficient. Larger radii can feel touch-friendly, playful, or premium. Uneven radii can communicate direction, emphasis, or a handmade visual style. The tool is most useful when you treat the numbers as part of a design decision rather than as arbitrary decoration.

Formula

At the geometric level, a rounded corner replaces a sharp ninety-degree corner with part of a curve. In the most common case, that curve is a quarter of a circle. More generally, CSS allows each corner to be based on an ellipse with a horizontal radius and a vertical radius. Those are usually written as rx and ry. When the two are equal, the result is circular. When they differ, the curve stretches in one direction and becomes elliptical.

The ellipse itself follows the familiar equation below. This matters because it explains why a corner can look wider than it is tall, or taller than it is wide, even though both are still valid rounded corners in CSS.

Formula: x^2 / r_x^2 + y^2 / r_y^2 = 1

x2 rx2 + y2 ry2 = 1

This calculator uses one number per corner and writes a four-value pixel declaration, so it effectively assumes a single radius for each corner rather than separate horizontal and vertical radii. In that simpler case, you can think of each corner as using rx = ry. That is exactly why the output feels straightforward: each corner gets one visible amount of rounding, and the browser handles the drawing.

There is one more practical rule worth knowing. CSS will not let corner radii overlap in a way that breaks the box. If the total horizontal radii on one side are too large for the element width, or the total vertical radii are too large for the element height, the browser scales them down proportionally. So although you might type very large values, the displayed shape may be gentler than the raw numbers suggest. That is not an error in the tool; it is standard CSS behavior.

Here is a plain-language worked example. Suppose you enter 24 for the top-left, 24 for the top-right, 0 for the bottom-right, and 0 for the bottom-left. The generated code becomes border-radius: 24px 24px 0px 0px;. Visually, the top edge feels softened while the bottom edge remains crisp. That combination is common in tabs, modal headers, and cards that sit flush against another surface below. If you instead enter 32 on every corner, the same box feels more button-like or mobile-friendly because all edges now curve inward evenly.

Elliptical radii are still important conceptually, even though this form does not expose them directly. If rx=2ร—ry, the corner looks twice as wide as it is tall. That is how CSS can produce stretched capsules, speech-bubble corners, and blob-like components without images. The preview here helps with the simpler four-number case, which is the most common starting point for UI work.

Usage Examples

CSS accepts several shorthand forms, and understanding them makes the generated output easier to reuse. The four-value form shown by this calculator is often the clearest because you can read each corner directly. Still, it helps to know how that fits into the broader syntax.

Common border-radius patterns and what they usually look like
Declaration Visual Effect
border-radius: 10px; All corners rounded equally
border-radius: 10px 20px; Top-left and bottom-right use 10px, while top-right and bottom-left use 20px
border-radius: 50%; Creates a circle if the element is square, or a capsule if it is rectangular
border-radius: 40px / 20px; Uses elliptical corners with a wider horizontal radius than vertical radius
border-radius: 0 30px 50px 0; Creates an intentionally directional shape often used in badges or callouts

One reason designers like rounded corners is that they guide attention inward. Sharp angles can pull the eye outward and feel severe, while curved edges often contain the content more gently. That is not a hard rule, but it is a useful design instinct. Modest radii tend to work well for dense dashboards and tables. Larger radii are common in mobile interfaces, onboarding cards, and touch targets because they feel approachable and finger-friendly. Extremely large or mixed radii can create personality, but they can also make an interface feel inconsistent if they are not repeated intentionally across a system.

The property is also efficient in modern browsers. A border radius does not require extra images or heavy markup, and it usually renders cheaply. The performance caveat is not the radius itself so much as the combination of radius with large shadows, filters, masks, or constant animation. If you are building a production component library, it is worth checking how those combinations behave on lower-powered devices.

Practical Workflow

A sensible workflow is to begin with a visual goal instead of a number. Ask whether the element should feel sharp, neutral, soft, or playful. Then use the linked mode to find a baseline radius that matches that mood. Once the overall softness feels right, unlink the corners only if the shape needs extra direction or personality. This keeps your decisions intentional. It also prevents the common mistake of over-customizing every corner before you know whether the overall component shape works.

Another useful habit is to compare the radius to the element size. A 12px radius can feel generous on a tiny chip but barely noticeable on a large content panel. In practical UI systems, teams often create a small radius scale such as 4, 8, 12, 16, and 24 pixels. A generator like this is helpful because you can preview those values on a consistent sample box and decide where each token belongs. Once chosen, those numbers can be reused across cards, inputs, alerts, menus, and modal windows.

If you are teaching yourself CSS, try pairing the tool with mental pattern recognition. Symmetrical values produce stable, orderly shapes. Opposite-corner repetition often feels decorative and dynamic. A single sharp corner among rounded corners can add direction, as if a badge is pointing somewhere. Over time, you stop seeing only numbers and start seeing reusable component personalities.

Limitations and Assumptions

This page intentionally keeps the calculator focused, and that means it has a few limits. First, the form uses four numeric inputs and outputs values in pixels, so it does not directly generate percentage radii or the slash syntax used for separate horizontal and vertical elliptical radii. CSS supports those cases, but this interface concentrates on the most common four-corner workflow. If you need 50% circles or a declaration like 40px / 20px, you will still need to edit the result manually after copying.

Second, the preview uses the browserโ€™s built-in rendering rules. That is good because it reflects real CSS behavior, but it also means very large radii may be visually adjusted when they would otherwise overlap. If the sum of two corner radii on one side is larger than the element size, the browser scales them to fit. In other words, the preview is honest to CSS, not to the raw number string alone. That is usually exactly what you want, but it is worth remembering when a huge input does not look as huge as expected.

Third, the tool shows only one sample box size. A radius that looks perfect on this preview may feel different on a much larger card or a much smaller button. Responsive design matters here. Percent-based radii respond to element dimensions automatically, while pixel-based radii stay fixed. Because this calculator outputs pixels, it is best used for quick prototyping, code generation, and learning the corner order, not as a substitute for testing the final component at its real dimensions.

Finally, border radius is only one part of the finished visual result. Padding, border width, shadow, background color, and surrounding layout all influence how soft or sharp a component appears. A subtle radius can disappear under a thick shadow, while a large radius can look natural when paired with a spacious layout. The calculator helps you isolate the curvature decision, but good UI design still depends on the full context around the shape.

Sample Corner Sets

The table below gives a few concrete value combinations to try in the form. These are not universal best practices; they are simply useful starting points for seeing how different distributions of corner values change the personality of the box.

Example top-left, top-right, bottom-right, and bottom-left values to test
Top-Left Top-Right Bottom-Right Bottom-Left Description
0 0 0 0 Sharp rectangle
20 20 20 20 Soft card or pill-like box if the element is short
50 10 50 10 Diagonal rhythm with a ribbon or badge feel
60 0 60 0 Directional edge useful for decorative callouts
100 100 0 0 Very soft top edge with a firm bottom edge

Broader Design Context

Rounded corners have a long history outside the web. Industrial design, architecture, packaging, and hardware interfaces have all used curves to soften edges and make objects feel more approachable. In early web design, rounded corners were often faked with extra images and nested markup because browsers lacked a reliable native property. Modern CSS removed that friction, so the design decision is no longer constrained by implementation cost. Today, the challenge is not whether you can round a corner, but whether you can do it consistently and intentionally.

That is why understanding border radius still matters. A design system with no curvature can feel stark and technical. A system with inconsistent curvature can feel accidental. A system with a well-chosen radius scale often feels more polished even when users cannot explain why. This calculator helps with that craft by linking visual feedback, code output, and the underlying geometry in one place. Use it when you want a quick value, but also use it to train your eye. The better you get at reading corner shapes, the faster your everyday CSS work becomes.

Live Preview and CSS Output

The preview box below updates as you type. The generated code always uses the clockwise order top-left, top-right, bottom-right, bottom-left, and the current calculator outputs values in pixels.

Live preview box showing the current border radius.

Copy the declaration into your stylesheet or component code, then adjust it further if you want percentages or elliptical slash syntax.

Mini-game: Corner Curve Match

This optional mini-game turns the same border-radius idea into a quick shape-matching challenge. Instead of typing values into the calculator, you drag the corners of a glowing box to match a target outline before the target window expires. It is a playful way to build instinct for which corners are linked visually, how big radii feel at a glance, and why repeating values creates recognizable patterns.

Score0
Time75.0s
Streak0
Progress0%
Best0

Corner Curve Match

Drag the four corner handles to match the glowing target shape. Every target has a short window, so accuracy and speed both matter.

  • Pointer or touch: drag a corner handle inward or outward.
  • Keyboard: press 1, 2, 3, or 4 to select a corner, then use arrow keys to adjust it.
  • Goal: match as many targets as possible in 75 seconds and build a streak.

Takeaway: in CSS shorthand, the four corner values move clockwise from top-left to bottom-left. The faster you recognize symmetry, the faster you can write and read border-radius code.

Embed this calculator

Copy and paste the HTML below to add the CSS Border Radius Generator | Live Rounded Corner Preview and Code to your website.