🏆 US-Registered Digital Marketing Agency Trusted by 200+ brands · USA · UK · Canada · AUS
Advertisement
Advertisement
CSS TOOLS

CSS Animation Generator — keyframes, timing and a live preview

Build a CSS keyframe animation with visual controls and copy the finished rule straight into your stylesheet.

Each preset animates only transform and opacity where possible — the two properties browsers animate most cheaply.
Ease-out suits elements entering the screen; ease-in suits elements leaving it.
Includes the keyframes, the animation shorthand, and a reduced-motion guard.
Total cycle time
0.60s
 
Keyframe stops
Properties animated
Compositor friendly
Iterations
Tip: animating transform and opacity keeps work on the compositor. Animating width, height, top, or left forces layout on every frame, which is where most janky animations come from.
Advertisement

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. Arb Digital built it that way deliberately — 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

  1. 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.
  2. Set the duration. Most interface animations belong between 150 and 500 milliseconds. Longer than about 700 and the interface starts to feel slow.
  3. Choose a timing function. Ease-out for elements arriving, ease-in for elements leaving, linear only for continuous motion such as a spinner.
  4. Set repetition and direction. Alternate reverses every other cycle, which is what makes a pulse read as breathing rather than snapping back.
  5. 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. A 600 millisecond animation with a 200 millisecond delay running three times occupies 2.0 seconds from the moment the element appears. That figure is worth watching, because delays compound quickly in staggered lists — ten items at 80 milliseconds of stagger means the last item does not begin moving until 800 milliseconds after the first.

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.

Advertisement

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 be handled by the compositor on an already-painted layer, skipping layout and paint entirely. 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 the usual approach is animating a scale transform or a grid template row instead.

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 shortens animations to a negligible duration and removes iteration when the preference is set.

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 guidance on motion from interactions covers the underlying requirement.

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.

Want interface motion that helps rather than distracts?

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 Development Services Talk to Arb Digital

Common 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. Beyond roughly 700 milliseconds an interface animation stops feeling responsive and starts feeling 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

How long should a CSS animation last?

Most interface animations sit between 150 and 500 milliseconds. Shorter feels abrupt, and much longer starts to feel like a delay rather than a transition.

Why does my element jump back after the animation?

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.

What is the difference between a CSS animation and a transition?

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.

Which properties are safe to animate for performance?

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.

How do I replay an animation that has already finished?

Remove the animation class, read a layout property such as offsetWidth to force the browser to register the change, then add the class back.

What does prefers-reduced-motion do?

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.

Do I still need vendor prefixes for CSS animations?

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.

Advertisement
Advertisement
Arb Digital assistant

👋 Hey! Want to grow your business? Ask me anything — a free marketing proposal is on the table!