CSS Animation / Keyframes Generator
Color Tools
Build CSS @keyframes animations visually. Set animation name, duration, timing function, and keyframe properties, then copy the complete CSS.
Keyframe stops
Add up to 8 stops and 6 properties per stop. Empty values are omitted from the CSS.
@keyframes fadeIn {
0% {
opacity: 0;
transform: translateY(-10px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
.animated {
animation: fadeIn 0.6s ease-out 0s 1 normal forwards;
}How to use this tool
- Choose a preset or enter an animation name and duration.
- Edit the start and end properties, and add intermediate keyframe stops as needed.
- Set timing, direction, iteration count, and fill mode, then play the preview.
- Compare the preview with the generated CSS and copy the result.
@keyframes syntax
CSS animations are defined with an @keyframes rule that describes the animation states:
@keyframes slide-in {
from {
transform: translateX(-100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
You can use from / to (equivalent to 0% / 100%) or any percentage values
to define intermediate states.
animation shorthand
The animation shorthand property packs all animation settings into one declaration:
animation: name duration timing-function delay iteration-count direction fill-mode; | Sub-property | Values | Description |
|---|---|---|
duration | 0.3s, 1500ms | How long one cycle takes. |
timing-function | ease, linear, ease-in-out, cubic-bezier() | Speed curve of the animation. |
delay | 0.2s, -500ms | Wait before starting. Negative values start mid-animation. |
iteration-count | 1, infinite, 2.5 | How many times to run. |
direction | normal, reverse, alternate, alternate-reverse | Whether to play forward, backward, or alternating. |
fill-mode | none, forwards, backwards, both | What state to hold before/after the animation runs. |
Timing function guide
- ease: starts moderately fast, decelerates - good default for most UI transitions.
- linear: constant speed - ideal for spinning loaders and continuous motion.
- ease-in: starts slow, ends fast - good for elements leaving the screen.
- ease-out: starts fast, ends slow - natural for elements entering the screen.
- ease-in-out: symmetric slow-fast-slow - polished feel for back-and-forth transitions.
prefers-reduced-motion
Users can enable a system-level preference for reduced motion (in OS accessibility settings). Respect this with a CSS media query to disable or simplify animations:
@media (prefers-reduced-motion: reduce) {
* {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
} This is a critical accessibility consideration. For users with vestibular disorders, motion sickness, or ADHD, excessive animation can cause physical discomfort or cognitive overload. Always test your animations with this setting enabled.
GPU compositing
For maximum performance, only animate properties that are GPU-composited: transform (translate, scale, rotate) and opacity. These bypass
layout and paint stages entirely, rendering on the GPU at 60fps. Avoid animating width, height, top, left, margin, or padding, as these trigger expensive layout reflows that can cause jank on
lower-end devices.
FLIP technique
The FLIP technique (First-Last-Invert-Play) is a pattern for animating layout changes smoothly using transforms. The steps:
- First: Record the element's initial position/size.
- Last: Apply the layout change (e.g., reorder DOM) and record the final state.
- Invert: Use
transformto move the element back to its original visual position. - Play: Transition
transformto zero, animating to the new layout.
This allows you to animate changes that would normally require layout recalculation (like reordering grid items) by faking the motion with GPU-accelerated transforms.
Frequently asked questions
What is a CSS keyframe animation?
@keyframes defines the stages of an animation. Set CSS properties at 0% and 100%, then add intermediate percentage stops when the motion needs a specific pose or pause.
How do I add an intermediate keyframe?
Choose Add stop to insert a stop in the largest available percentage gap, edit its offset, and add CSS properties. Stops are sorted by percentage in the generated CSS.
How can I use a custom easing curve?
Choose Custom cubic-bezier() under Timing function and paste a curve from the Bezier Editor. The first and third coordinates must be between 0 and 1; the other two can overshoot.
What does alternate animation direction do?
The alternate direction plays odd iterations forward and even iterations backward. Pair it with an infinite iteration count for a repeating pulse or bounce.
Related tools
- Bezier EditorBuild a cubic-bezier() curve and paste it into the custom timing function.
- CSS LoadersCreate a focused loading animation from reusable CSS shapes.
- CSS Transition VisualizerCompare CSS transition timing and property changes for simpler state-to-state motion.
- CSS Filter GeneratorAdd animated brightness, blur, hue, or saturation changes to the effect.