CSS Keyframes Generator

Add keyframe stops, set a transform and opacity for each, and watch the animation run as you edit. You get both the @keyframes block and the animation shorthand, ready to paste. Presets cover the animations people actually write — fade, slide, pulse, shake, bounce and spin — as starting points rather than finished answers. Stops are sorted before output, because a block that jumps from 100% to 0% to 50% behaves identically and is miserable to maintain, and the animation name is sanitised into a legal identifier, since CSS rejects a name starting with a digit and gives no obvious clue why. Before you ship any of this, wrap it in a prefers-reduced-motion query — for some people animation causes genuine nausea, not mild annoyance.

animation shorthand order

PositionPropertyNote
1nameMust be a legal CSS identifier
2durationFirst time value wins
3timing-functionease, linear, cubic-bezier(...)
4delaySecond time value
5iteration-countA number, or infinite
6directionnormal, reverse, alternate
7fill-modeforwards keeps the final state

When to use it

  1. Write a fade-and-slide entrance for a component.
  2. Build a loading pulse or spinner animation.
  3. Create an attention shake for a form error.
  4. Prototype a motion idea before committing it to code.
  5. Learn @keyframes syntax by seeing it change live.

How to Use

  1. Pick a preset, or add keyframe stops yourself.
  2. Set transform and opacity at each stop, and adjust the timing.
  3. Copy the @keyframes and animation shorthand.

Features

  1. Unlimited keyframe stops with transform and opacity
  2. Duration, delay, repeat, direction and fill mode
  3. Six presets covering the common animations
  4. Live preview with replay
  5. Stops sorted and names sanitised automatically
  6. Reduced-motion guidance included

FAQs

What is the difference between @keyframes and animation?

@keyframes defines what happens — the states at each point through the sequence. animation attaches it to an element and says how long, how many times, and with what easing. You need both, which is why this tool outputs both.

Why does the order of values in the shorthand matter?

Because duration and delay are both times, and CSS reads the first one it finds as the duration and the second as the delay. Write them the wrong way round and a 0.3s animation with no delay becomes a 0.3s delay with no animation, which looks like nothing happening. Duration is always written first here.

What does fill-mode do?

Decides what the element looks like before the animation starts and after it ends. Without it, the element snaps back to its original state the moment the animation finishes — which is why a fade-in often flashes back to invisible. forwards keeps the final state; both keeps the first state during any delay as well.

Why won't my animation name work?

Most likely it starts with a digit or contains a space. CSS identifiers cannot begin with a number, so 3d-spin is invalid and the rule is discarded with no error you would notice. Names are sanitised automatically here.

What is prefers-reduced-motion and do I have to use it?

A system setting people turn on when movement on screen causes them problems — for those with vestibular disorders, large animations can cause real nausea and dizziness. Wrapping your animation in @media (prefers-reduced-motion: no-preference) means it simply does not run for them. It costs two lines and it is the difference between a site someone can use and one they cannot.

Should I animate transform or top and left?

Transform, almost always. Transform and opacity can be handled by the compositor without recalculating layout, so they stay smooth; animating top, left, width or height forces the browser to re-layout every frame and visibly stutters.

Technical Details

Keyframe stops are sorted into ascending order before being written out. Out-of-order stops are perfectly legal CSS and behave identically, but a block that jumps from 100% to 0% to 50% is unreadable, and this is code somebody has to maintain. An empty transform is omitted rather than emitted as a bare declaration, since transform with no value is invalid and would silently kill the whole rule in some parsers. The animation name is sanitised into a legal CSS identifier: spaces become hyphens, runs collapse, and a name starting with a digit is prefixed, because CSS identifiers cannot start with a number and a name like 3d-spin would break the rule without any obvious cause. The shorthand's argument order is load-bearing in one specific place — duration comes before delay, and both are times, so swapping them turns a 0.3s animation with no delay into a 0.3s delay with no visible animation. The generator always writes duration first. Direction and fill-mode are omitted when they hold their default values, keeping the output close to what a person would type. The reduced-motion note is included deliberately rather than as boilerplate: prefers-reduced-motion exists because vestibular disorders make certain animation genuinely nauseating, and a generator that hands people animation code without mentioning it is part of the problem.

Web & CSS Tools

Web & CSS Tools

  • CSS Unit Converter
  • Layout Grid Calculator
  • Design Tokens Converter
  • SVG Sprite Builder
  • Font Subsetter and WOFF2 Converter
  • Viewport Meta Tag Generator
  • Web App Manifest Generator
  • CSS Button Generator