Live preview
The generated CSS includes a prefers-reduced-motion block that turns the animation off for visitors who ask for reduced motion — keep it in your stylesheet. None of the presets flashes or strobes: they move or fade gently, and the animation runs on transform and opacity, which browsers handle smoothly. The animation shorthand lists, in order, the name, duration, timing function, delay, iteration count, direction, fill mode and play state.
What is the CSS Animation Generator?
The CSS Animation Generator is a free online tool that builds a CSS animation for you — no hand-written keyframes needed. You pick a preset such as Fade In or Bounce, adjust the timing, edit the keyframes, and watch the result play in a live preview. When it looks right, you copy the generated CSS and HTML and paste them into your own page. It is made for anyone who wants movement on a page without learning the whole animation syntax first: beginners adding their first fade-in, bloggers drawing attention to a button, and developers who want a correct starting point fast.
An animation in CSS has two parts: the @keyframes rule, which describes what changes over time, and the animation property, which says which keyframes to use, how long it runs and whether it repeats. This tool writes both parts for you, and every change updates the preview and the code together.
Everything runs in your browser. There is no sign-up, no account, and nothing you type leaves your device.
How to use the CSS Animation Generator
- Pick a preset. The Preset dropdown offers eight starting points: Fade In, Slide Up, Bounce, Spin, Pulse, Shake, Slide In Left and Zoom In. Fade In is selected by default. Choosing a preset loads its keyframes and sets the animation name to match.
- Name your animation. The Animation name field holds the name used in the
@keyframesrule and theanimationshorthand. The tool removes any characters that are not allowed in a CSS name, and if the name is empty or starts with a digit it falls back tomyAnimation. - Set the timing. Duration (seconds) controls how long one run takes — the default is 1 second. Delay (seconds) waits before the animation starts. Timing function controls the easing: ease, linear, ease-in, ease-out, ease-in-out, ease-out-back, or a custom cubic-bezier with four numbers of your own (the defaults are 0.68, -0.55, 0.27, 1.55).
- Choose how it repeats. Iteration count sets the number of runs. Tick Loop forever (infinite) to make it run without stopping — the count field is disabled while looping is on. Direction can be normal, reverse, alternate or alternate-reverse. Fill mode decides what the element looks like before and after the animation: none, forwards, backwards or both. Play state is running or paused.
- Edit the keyframes. Each keyframe stop has a percentage and fields for opacity, X (px), Y (px), Scale and Rotate (°). Leave a transform box empty to leave that property out of the stop. Use Add keyframe to add a stop — it is placed 10% after the last one — and Remove to delete one. An animation needs at least one keyframe.
- Watch the preview and replay it. The Live preview shows a red box labelled “Animated element” playing your animation. Press Replay to watch it from the start.
- Copy the code. Copy CSS takes the full generated CSS; Copy HTML takes the element to use it on. Reset returns everything to the Fade In preset.
Worked example: a gentle fade-in
Leave the preset on Fade In with a duration of 1 second. The tool generates this CSS:
@keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.animated-element {
animation: fadeIn 1s ease 0s 1 normal none running;
}
@media (prefers-reduced-motion: reduce) {
.animated-element {
animation: none;
}
}
The HTML to use it on is a single line:
<div class="animated-element">Your content here</div>
Now change the duration to 2 and tick Loop forever (infinite). The shorthand becomes fadeIn 2s ease 0s infinite normal none running, and the preview box fades in and out for as long as the page is open. That is the whole workflow: adjust, watch, copy.
Animations that make a page feel alive
Fade a hero heading in on load. A heading that fades in over one second feels calm and finished, where a heading that simply appears can feel abrupt. Use the Fade In preset, a duration of about 1 second, and fill mode forwards so the heading stays fully visible at the end. This is the most common use of the tool, and it works on headlines, hero images and intro paragraphs alike.
Draw the eye to a button with a pulse. A call-to-action button that grows slightly, over and over, is hard to ignore without being annoying. Use the Pulse preset, which scales the element from 1 to 1.1 and back, with Loop forever (infinite) switched on and a duration of about 1.5 to 2 seconds. Keep it subtle — a small scale change reads as a nudge, while a large one reads as a warning.
Spin a loading indicator. A spinner is the classic looping animation. Use the Spin preset, which rotates the element from 0 to 360 degrees, with Loop forever (infinite) on, a duration of about 1 second, and the timing function set to linear so the speed stays constant.
Tips for better CSS animations
- Animate transform and opacity. The presets only move, scale, rotate and fade — never width, height or margins. Browsers handle transform and opacity smoothly because they do not force the page to re-lay itself out on every frame. If your animation feels jerky, check that you are not animating a layout property.
- Keep durations short. Most good animations run between 0.3 and 1 second. Longer than that, and the movement starts to feel slow rather than smooth. Use the delay field when you want something to wait — for example, a heading that fades in half a second after the page loads.
- Use fill mode forwards for one-off entrances. With fill mode set to none, an element returns to its original state when the animation ends — so a fade-in that ends at full opacity snaps back to invisible if the element started invisible. Forwards keeps the final keyframe applied after the animation finishes.
- Mind the timing function. Ease is the default because it starts and ends gently. Linear is the right choice for a spinner, where constant speed matters. The custom cubic-bezier option lets you fine-tune the curve with four numbers — the ease-out-back default (0.68, -0.55, 0.27, 1.55) overshoots slightly, which gives a springy, playful feel.
- Keep the reduced-motion block. The generated CSS ends with a
@media (prefers-reduced-motion: reduce)block that turns the animation off for visitors who have asked their system for reduced motion. Leave it in your stylesheet — it costs nothing and makes your site kinder to people who are sensitive to movement. The preview in the tool respects the same setting.
Frequently asked questions
Do I need to know CSS to use this tool?
No. Pick a preset, change the numbers, and watch the preview. The tool writes the CSS for you, and the shorthand it generates follows the standard order: name, duration, timing function, delay, iteration count, direction, fill mode and play state.
What is a keyframe?
A keyframe is a snapshot of the element at one point in the animation, marked by a percentage. The browser fills in the steps between your keyframes. The Fade In preset has two: 0% with opacity 0 (invisible) and 100% with opacity 1 (fully visible). Add a stop at 50% and you can make the animation pass through a middle state — for example, sliding halfway and pausing.
Why does my animation not repeat?
Check the Iteration count and the Loop forever (infinite) checkbox. An iteration count of 1 means the animation runs once and stops. Set the count higher, or tick Loop forever (infinite) to make it run without stopping. Direction set to alternate makes each repeat run backwards, which is useful for a gentle back-and-forth.
What does fill mode do?
Fill mode decides what the element looks like outside the animation’s running time. With none, the element looks exactly as your stylesheet says before the animation starts and after it ends. With forwards, it keeps the final keyframe after the animation finishes. With backwards, it takes the first keyframe during the delay before the animation starts. Both applies both behaviours.
Will the animation respect visitors who prefer reduced motion?
Yes. The generated CSS includes a prefers-reduced-motion block that switches the animation off for those visitors, and the tool’s own preview does the same. Keep that block in your stylesheet when you paste the CSS into your site.
Conclusion
The CSS Animation Generator takes the fiddly part out of CSS animation: you choose how something should move, and it writes the keyframes, the shorthand and the reduced-motion fallback for you. Try the Fade In preset on a heading or the Pulse preset on a button, and copy the code when it looks right. And when you need a background to match, pair it with the CSS Gradient Generator.

