CSS Animation Generator
Create keyframe animations visually with presets, live preview, and copy-ready CSS.
How it works
- 1
Choose a preset or start fresh
Load a preset animation or begin with your own custom keyframes.
- 2
Set timing options
Adjust the name, duration, timing function, iteration count, and direction.
- 3
Edit keyframes
Tune translation, rotation, scale, opacity, and color at each keyframe step.
- 4
Copy the CSS
Copy the generated @keyframes block and animation shorthand into your project.
Common use cases
Bounce call-to-action
Bounce preset with 1.2s duration
Fade in reveal
Two keyframes with opacity and upward movement
About This Tool
Build CSS animations without hand-writing keyframes. Set an animation name, duration, timing function, iteration behavior, and direction, then edit any number of keyframes with transform, opacity, and background color controls. A live preview box plays the animation instantly so you can tune motion with confidence.
Preset motions like Bounce, Fade In, Slide In, Pulse, Spin, and Shake help you start quickly, while the full generated CSS includes both the @keyframes block and an animation shorthand declaration. This is ideal for interface prototyping, marketing components, loading states, and motion design experimentation.
CSS animations bring interfaces to life by transitioning properties smoothly between defined states using keyframes. Each keyframe specifies the property values at a particular point in the animation timeline (0%, 25%, 50%, 75%, 100%, etc.). The browser interpolates between these keyframes to create smooth motion.
The animation shorthand property combines eight sub-properties: name, duration, timing-function, delay, iteration-count, direction, fill-mode, and play-state. The most common pattern is: animation: fadeIn 0.3s ease-out forwards. The name references your @keyframes block, the duration sets how long one cycle takes, the timing function controls the acceleration curve, and fill-mode determines whether styles apply before or after the animation runs.
Timing functions control the acceleration and deceleration of your animation. Ease (default) starts slow, speeds up, then slows down. Linear maintains constant speed. Ease-in starts slow and accelerates. Ease-out starts fast and decelerates. Ease-in-out starts slow, speeds up, then slows down. Custom cubic-bezier curves give you precise control over the timing. For natural-feeling motion, ease-out is generally preferred for entrance animations and ease-in for exit animations.
The animation-fill-mode property is often overlooked but critical for correct behavior. Forwards ensures the element retains the final keyframe styles after the animation completes — without it, the element snaps back to its original state. Backwards applies the first keyframe styles immediately, even during a delay. Both combines both behaviors.
Transform-based animations (translate, rotate, scale) are GPU-accelerated and perform significantly better than animating layout properties like width, height, top, or left. Always prefer transform and opacity for animations, as these properties do not trigger layout recalculations and can be composited on the GPU.
Performance best practices: Animate only transform and opacity when possible. Use will-change: transform on elements that will animate to hint the browser to optimize compositing. Avoid animating box-shadow (use a pseudo-element approach instead), and use contain: layout on containers with animated children to limit the scope of browser recalculations.
Common animation patterns for UI: Fade in for revealing content (opacity 0 to 1 with a slight upward translate), scale up for new elements appearing (scale 0 to 1 with ease-out), slide in for navigation drawers and modals (translate from off-screen), and pulse for drawing attention (subtle scale oscillation). Keep durations between 150ms and 500ms for UI feedback — shorter feels snappy, longer feels smooth. For decorative or marketing animations, longer durations of 1-3 seconds are appropriate.
More examples
Examples
Bounce call-to-action
Input
Bounce preset with 1.2s duration
Output
@keyframes block plus animation shorthand for a lively button effect
Fade in reveal
Input
Two keyframes with opacity and upward movement
Output
Simple reveal animation ready for cards or modals
Frequently Asked Questions
- What properties can I animate?
- Each keyframe lets you control translate X and Y, rotation, scale, opacity, and background color, which covers a wide range of UI motion patterns. These properties are chosen because transform and opacity are GPU-accelerated for smooth performance.
- Does the preview really play the animation?
- Yes. The preview uses the generated keyframes and animation settings directly so you can see the current motion while editing. Changes are reflected in real time as you adjust any parameter.
- Can I make an animation loop forever?
- Yes. Set the iteration count to infinite for continuous looping, or set a specific number if you want the motion to stop after a fixed number of runs. For loading spinners and background effects, infinite is appropriate.
- What code do I get back?
- The tool outputs a full @keyframes block and a matching animation shorthand declaration that you can paste directly into your stylesheet. The output uses standard CSS syntax compatible with all modern browsers.
- What is the best duration for UI animations?
- For UI feedback (button presses, toggles, reveals), use 150-300ms. For larger transitions (modals, page sections), use 300-500ms. For decorative or marketing animations, 1-3 seconds is appropriate. Durations under 100ms feel instant rather than animated.
- What is animation-fill-mode and why does it matter?
- fill-mode controls whether styles apply before and after the animation runs. Forwards retains the final keyframe styles after completion — without it, the element snaps back to its pre-animation state. This is essential for entrance animations like fade-in.
- Should I use CSS animations or JavaScript animations?
- Use CSS animations for simple, declarative motion that runs on the compositor thread (transform and opacity). Use JavaScript (Web Animations API or libraries like GSAP) for complex sequences, physics-based motion, scroll-driven effects, or when you need to control playback programmatically.
- What timing function should I use?
- Ease-out is best for entrance animations (elements arriving feels natural). Ease-in works for exit animations (elements leaving feel like they are accelerating away). Linear is for continuous motion like spinners. Custom cubic-bezier curves give you precise control for unique motion personalities.
Learn More
Related Guides
Discover More Tools
View all Design Tools →CSS Flexbox Generator
Build flex layouts visually and copy both raw CSS and Tailwind-ready utility output.
CSS Gradient Generator
Create linear, radial, and conic CSS gradients with a visual editor.
CSS Shadow Generator
Create multi-layer box shadows with a visual editor and live preview.
CSS Unit Converter
Convert between px, rem, em, vw, vh, %, and pt.