A CSS animation generator removes the tedious part of keyframe work: writing the rule, reloading, watching the element move slightly wrong, adjusting a number, reloading again. Here the preview updates as you change each control, so you tune the timing against what you can actually see and copy the finished CSS once it looks right.
Every preset in this tool animates transform and opacity wherever the effect allows, because those are the two properties a browser can animate without recalculating layout. The presets are built that way on purpose: an animation that looks smooth on a development machine and stutters on a mid-range phone is usually animating the wrong property, not running too long.
What This CSS Animation Generator Does
Choose an effect, set duration, delay, timing function, iteration count, direction, and fill mode, and the tool writes the matching @keyframes block and animation shorthand. The preview element runs the animation live, and the replay button restarts it so you can watch a one-shot entrance animation as many times as you need.
The result panel reports the facts that matter for performance and behaviour: the total cycle time including delay, how many keyframe stops the effect defines, which properties change, whether those properties are compositor friendly, and how many times the animation runs. The generated CSS also includes a prefers-reduced-motion guard, which is the accessibility requirement most hand-written animation code forgets.
How to Use It
- Pick an effect from the animation list. Entrances such as fade and slide are the most common use; pulse, spin, and shake are attention or status effects.
- Set the duration. A common rule of thumb puts interface animations between 150 and 500 milliseconds. Past about 700 they tend to feel slow. These are conventions, not standards, so judge by feel.
- Choose a timing function. Ease-out for elements arriving, ease-in for elements leaving, linear only for continuous motion such as a spinner.
- Set repetition and direction. Alternate reverses every other cycle, which is what makes a pulse read as breathing rather than snapping back.
- Copy the CSS and apply the class to your element. Keep the reduced-motion block that comes with it.
The Formula / How It's Calculated
A CSS animation has two halves. The @keyframes rule defines what changes and at which points in the cycle, expressed as percentages from 0 to 100. The animation property on the element defines how that sequence is played: which keyframes, for how long, with what easing, after what delay, how many times, in which direction, and what happens before and after.
Total cycle time is delay plus duration multiplied by iteration count. The delay is paid once, before the first iteration, not before each repeat. A 600 millisecond animation with a 200 millisecond delay running three times occupies 200 + 3 × 600 = 2,000 ms, or 2.0 seconds, from the moment the element appears. That figure is worth watching, because delays compound in staggered lists: ten items staggered by 80 milliseconds means the last one starts nine gaps later, 720 milliseconds after the first, and finishes 720 ms plus its own duration after it.
Timing functions are cubic Bézier curves mapping elapsed time to progress. The named keywords are shorthands for specific curves: ease-out starts fast and decelerates, ease-in does the reverse. A custom curve with a control point above 1 overshoots the end value and settles back, which is how a spring-like effect is produced without any physics engine. The steps() function is different in kind: it jumps between discrete states rather than interpolating, which is how sprite-sheet and typewriter effects are built. Full definitions live in the W3C CSS easing functions specification.
Why Transform and Opacity Are the Only Cheap Properties
Rendering a frame involves style calculation, layout, paint, and composite. Animating a geometric property such as width, height, top, or margin invalidates layout, which forces the browser to recompute the position of the element and potentially everything around it, then repaint, then composite — every single frame.
Transform and opacity are different. Both can usually be handled by the compositor on an already-painted layer, which lets the browser skip layout and paint for each frame. That is why transform: translateX(20px) and left: 20px look identical and perform nothing alike. On a desktop machine the difference may be invisible; on a mid-range phone rendering a list, it is the difference between smooth motion and visible stutter.
This is also why the compositor-friendly indicator in the results panel matters. If it says no, the animation is doing layout work per frame and should be rewritten in terms of transform where the effect allows. The one common exception is animating height for an accordion, which has no clean transform equivalent — there is no clean transform equivalent, so the cost is layout work on every frame. Keep such panels small and short, and test on a slow device.
Fill Mode: The Setting That Explains the Snap-Back
The most common animation bug is an element that animates beautifully into place and then jumps back to where it started. The cause is fill mode. By default, an animation applies its keyframe values only while it is running; the moment it finishes, the element reverts to whatever the underlying CSS says.
Setting fill mode to forwards holds the final keyframe after the animation ends. Setting it to backwards applies the first keyframe during the delay period, which stops an element from being briefly visible in its pre-animation state before a delayed fade-in begins. both does each, and it is the sensible default for entrance animations, which is why this generator selects it.
Respecting Reduced Motion Is Not Optional
Vestibular disorders make large-scale motion genuinely unpleasant, and some people simply prefer interfaces that hold still. Operating systems expose that preference, and CSS reads it through the prefers-reduced-motion media query. The generated CSS includes a block that sets the duration to 0.01 ms and the iteration count to 1 when the preference is set (see MDN's prefers-reduced-motion reference). It does not touch the delay, so a long delay still holds the element in its starting state for that time.
Note the approach: reduce rather than remove. Setting animation: none can break interfaces that depend on a fill-mode end state to be visible at all, because the element never reaches its final keyframe. Collapsing the duration to near zero preserves the end state while removing the motion, which is safer across a codebase you do not fully control. The W3C's Understanding guide to Animation from Interactions (a Level AAA criterion) explains why non-essential motion can trigger dizziness and nausea for some people.
Animation Versus Transition, and When Each Fits
A transition interpolates between two states and needs something to trigger the change — a hover, a class toggle, a state update. An animation runs from its own keyframe timeline and starts as soon as it is applied, with no trigger required. That distinction decides which tool fits.
Hover effects, focus rings, and open-and-close toggles are transitions: there are exactly two states and a clear event moving between them. Entrance animations, loading spinners, attention pulses, and any sequence with more than two stops are animations. Using an animation where a transition would do usually means writing more code and losing the automatic reversal a transition gives you for free when the state flips back.
Restarting an Animation That Has Already Run
Once an animation has finished, reapplying the same class does nothing — the browser sees no change. This trips people up constantly when trying to replay an effect on demand. The reliable fix is to remove the class, force the browser to acknowledge the removal by reading a layout property such as offsetWidth, then add the class back.
That is exactly what the replay button here does. The alternative is listening for the animationend event and cleaning up there, which is tidier in a component-based codebase because it keeps the reset next to the completion rather than next to the trigger.
How to Read the Result
- Total cycle time is delay plus duration times iterations. With "Repeat forever" it shows one cycle including the delay.
- Keyframe stops counts the percentage points the preset defines, such as 0% and 100% for two.
- Properties animated lists what the preset changes.
- Compositor friendly is "Yes" when every listed property is transform or opacity. The tool reads this from the preset's property list; it does not measure real frame times, so test on a slow device.
- Iterations shows your count, or the infinity sign when repeat forever is on.
Four starting points to try:
| Scenario | Settings | Cycle time | Sub-line | Stops | Properties - compositor friendly |
|---|---|---|---|---|---|
| Default: slide up | slide-up, 600 ms, delay 0, 1 run | 0.60s | Delay 0.00s plus 1 × 0.60s | 2 | transform, opacity - Yes |
| Delayed fade-in | fade-in, 400 ms, delay 200 ms, 1 run | 0.60s | Delay 0.20s plus 1 × 0.40s | 2 | opacity - Yes |
| Attention shake | shake, 500 ms, delay 0, 3 runs | 1.50s | Delay 0.00s plus 3 × 0.50s | 5 | transform - Yes |
| Loading spinner | spin, 1000 ms, linear, repeat forever | 1.00s | One cycle including delay - repeats indefinitely | 2 | transform - Yes |
What to Do Next
- Pick the effect, then tune the duration until the preview feels right at normal speed rather than by the number.
- Keep fill mode on "both" for entrances so the element does not flash before a delay or jump back afterwards.
- Copy the CSS, including the reduced-motion block, and add the
arb-animateclass to your element. - Rename the class and keyframes to fit your project, then test with your operating system's reduce-motion setting turned on.
Arb Digital's web development team builds interfaces where animation supports comprehension, respects motion preferences, and stays smooth on the devices your visitors actually use.
Web Design Services Talk to Arb DigitalCommon Mistakes to Avoid
- Animating layout properties. Width, height, top, and left force layout every frame; use transform instead wherever the effect allows.
- Durations that are too long. As a rule of thumb, beyond roughly 700 milliseconds an interface animation starts to feel like a wait.
- Forgetting fill mode. Without it the element snaps back to its starting state the instant the animation ends.
- Ignoring reduced-motion preferences. Large motion can cause real discomfort, and the media query costs three lines to honour.
- Running infinite animations on non-essential elements. They keep the compositor busy and drain battery for no informational gain.
Related Free Tools From Arb Digital
Lay out the elements you are animating with the CSS flexbox generator or the CSS grid generator, style them with the CSS gradient generator, box shadow generator, or border radius generator, scale type fluidly using the CSS clamp generator, and compress the finished stylesheet with the CSS minifier. Everything else is in the free online tools hub.
Frequently Asked Questions
Many designers use roughly 150 to 500 milliseconds for interface animations as a rule of thumb. Much shorter feels abrupt, and much longer starts to feel like a delay rather than a transition.
The fill mode is set to none, so the keyframe values stop applying once the animation ends. Setting it to forwards or both holds the final keyframe in place.
A transition interpolates between two states and needs an event to trigger it. An animation runs its own keyframe timeline as soon as it is applied and can have many stops.
Transform and opacity, because both can be handled by the compositor without recalculating layout or repainting. Geometric properties such as width and top force layout on every frame.
Remove the animation class, read a layout property such as offsetWidth to force the browser to register the change, then add the class back.
It exposes the operating system setting where a user has asked for less motion. Wrapping animations in that media query lets you shorten or simplify them for anyone who has opted out.
Not for current browsers. Unprefixed animation and keyframes syntax has been supported broadly for years, so prefixes only matter if you must support very old versions.
Preview rendering depends on your browser and device. Test animations on the lowest-powered device your audience uses before shipping.