Embed this tool on your site
About this tool
CSS animations defined by @keyframes let you bring interfaces to life with fades, slides and rotations that play without any JavaScript. Writing the keyframe block and the animation shorthand from scratch is tedious when you just want a working starting point. The CSS Keyframes Generator builds a two-stop animation: a from and a to stop, each with a transform value and an opacity. Pick a preset — Fade, Slide Up, Slide Left or Rotate In — or type your own transforms, then set the animation name, duration (rounded to 0.1s), easing keyword (ease, linear, ease-in, ease-out, ease-in-out) and an iteration count or Infinite. The output pairs the @keyframes block with an .anim rule carrying the animation shorthand, ready to paste. There is no on-page motion preview, so test the copied CSS in your project. Note that a To opacity of 0 is currently written as 1, so fade-outs need a manual edit after copying.
Why use it
From/To Builder: Each animation has a from and a to stop with a transform and an opacity — enough for fades, slides, rotations and scale-ins without writing the boilerplate by hand.
Starter Presets: Fade, Slide Up, Slide Left and Rotate In fill the from/to fields with tested values that you can then tweak.
Easing Keywords: Choose ease, linear, ease-in, ease-out or ease-in-out from a dropdown and the value goes straight into the animation shorthand.
Free-Form Transforms: The transform fields accept any CSS transform list, so you can combine functions such as translateY(24px) scale(0.95) in a single stop.
Copy Block: The output includes the named @keyframes block and an .anim rule with the animation shorthand together. Forgetting to add the animation declaration after writing keyframes is a common mistake; this generator outputs both so the element animates immediately after pasting.
How to use
- Type an Animation name (spaces become hyphens)
- Pick a Preset — Fade, Slide Up, Slide Left or Rotate In — or keep Custom
- Edit the From/To transform fields (any transform value, e.g. translateY(24px)) and From/To opacity (0–1)
- Set Duration in seconds and choose an Easing: ease, linear, ease-in, ease-out or ease-in-out
- Set an Iteration count or tick Infinite
- Click Copy CSS to grab the @keyframes block and the .anim animation rule together
When it helps
- When adding an entrance animation to a card, toast notification, or modal that should slide and fade in
- When adding a continuous spin to an icon with rotate(0deg) to rotate(360deg), linear easing and Infinite
- When prototyping a slide-in for a dropdown or side panel before tuning it in your codebase
- When teaching how @keyframes from/to stops pair with the animation shorthand
- When generating a named starter animation to extend with extra percentage stops by hand
- When implementing a scroll-triggered reveal animation and need to define the from and to states
Examples
InputName fadeInUp, Duration 0.5, Easing ease-out, Iteration 1, From translateY(20px) / opacity 0, To translateY(0) / opacity 1
Expected result · Scroll for more@keyframes fadeInUp {
from {
transform: translateY(20px);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
.anim {
animation: fadeInUp 0.5s ease-out 1;
}
InputName spin, Duration 1, Easing linear, Infinite, From rotate(0deg) / opacity 1, To rotate(360deg) / opacity 1
Expected result · Scroll for more@keyframes spin {
from {
transform: rotate(0deg);
opacity: 1;
}
to {
transform: rotate(360deg);
opacity: 1;
}
}
.anim {
animation: spin 1.0s linear infinite;
}
InputName rotateIn, Preset Rotate In, Duration 0.8, Easing ease, Iteration 1
Expected result · Scroll for more@keyframes rotateIn {
from {
transform: rotate(-12deg);
opacity: 0;
}
to {
transform: rotate(0deg);
opacity: 1;
}
}
.anim {
animation: rotateIn 0.8s ease 1;
}
Tips
- Animate transform and opacity exclusively where possible — they are composited on the GPU and produce consistently smooth 60fps motion without triggering layout
- Set animation-fill-mode: forwards on entrance animations so the element stays visible after the animation completes instead of snapping back to its initial invisible state
- Wrap all non-essential animations in @media (prefers-reduced-motion: no-preference) to respect users with vestibular disorders or motion sensitivity settings
- Negative animation-delay (e.g. -0.5s) starts the animation mid-cycle immediately, useful for staggered lists where you want items offset in phase rather than all starting from scratch
- Stack multiple opacity and transform stop values in one @keyframes block rather than creating separate overlapping animations for coordinated entrance effects
Frequently Asked Questions
What is the difference between @keyframes and transition?⌄
Transitions animate between two states triggered by a user action or state change. @keyframes define multi-stop animations that run on their own timeline, can loop, reverse, delay, and play without any trigger. Use transitions for interactive state changes and keyframes for autonomous, orchestrated motion.
How do I make an animation play once and stop at the end?⌄
Set animation-iteration-count: 1 (the default) and animation-fill-mode: forwards. The forwards fill mode keeps the element in the state defined at the final keyframe after the animation completes, preventing it from snapping back to its initial state.
What does animation-fill-mode: forwards do?⌄
forwards tells the browser to keep the element in the state of the last keyframe after the animation finishes. Without it, the element snaps back to its pre-animation CSS values, which makes entrance animations suddenly disappear after playing.
How do I pause animation on hover?⌄
Add animation-play-state: paused to the :hover rule on the animated element. The animation freezes in place when the cursor enters the element and resumes from the same point when the cursor leaves.
Can I run multiple animations on the same element?⌄
Yes. The animation property accepts a comma-separated list of animation values. Each entry in the list corresponds to a separate @keyframes name with its own duration, easing, delay, and iteration count. Multiple animations compose additively on the element.
Should I animate transform or top/left for performance?⌄
Always animate transform and opacity when possible. These properties are GPU-composited and do not trigger layout or paint. Animating top, left, width, height, or any layout-affecting property causes layout recalculation on every frame, producing janky animations on complex pages.
What is a cubic-bezier easing curve?⌄
cubic-bezier() defines a custom easing curve using four control-point values between 0 and 1. The built-in keyword easings like ease and ease-in-out map to specific cubic-bezier values. Custom curves let you define spring-like overshoots, immediate starts, or exaggerated decelerations.
How do I respect prefers-reduced-motion in animations?⌄
Wrap your animation declarations in @media (prefers-reduced-motion: no-preference) { } so they only apply when the user has not requested reduced motion. For motion-critical UIs, provide a static alternative in @media (prefers-reduced-motion: reduce) that conveys the same information without movement.
Glossary
- Keyframe
- A percentage stop within a @keyframes rule that defines the CSS property values at that point in the animation timeline. 0% is the start; 100% is the end; intermediate stops control the path between.
- Animation Timing Function
- Controls how an animation progresses over its duration — whether it accelerates, decelerates, or moves at a constant rate. Applied per-keyframe or to the overall animation via the animation-timing-function property.
- Cubic Bezier
- A mathematical curve defined by four control points used to describe custom animation easing. css built-in easings like ease map to specific cubic-bezier() values; custom curves enable spring, bounce, and other non-standard motion profiles.
- Iteration Count
- The number of times an animation plays, set by animation-iteration-count. Use a number for finite repetitions or the keyword infinite for continuous looping.
- Animation Delay
- The time before an animation starts, set by animation-delay. Negative values skip that duration into the animation timeline, useful for staggering items in a list.
- Fill Mode
- Controls the element's state before or after animation play. forwards keeps the final keyframe state; backwards applies the first keyframe during delay; both applies both behaviors simultaneously.
A LITTLE HELP. A LOT DONE.
Good tools.
Great flow.
Your shortcut to the everyday. Create, convert, calculate,
and get back to what you love.
✳
✳
✓ Free to use✓ No sign-up✓ 500+ possibilities