Smooth Scroll CSS & JS Generator
Generate smooth scroll code for your website. Choose CSS scroll-behavior, vanilla JavaScript with custom easing, or Lenis library configuration — then copy the ready-to-use code.
Live Preview
How Does the Smooth Scroll Generator Work?
The Smooth Scroll Generator creates ready-to-use code snippets that add smooth scrolling behavior to any website. Instead of the browser jumping instantly to anchor links or page sections, smooth scrolling animates the transition so users can follow the page movement and maintain spatial context. This tool supports three methods: native CSS scroll-behavior, a custom vanilla JavaScript implementation with configurable easing functions, and the popular Lenis smooth scroll library used by award-winning websites.
Simply choose your preferred method, adjust the options to match your project needs, and click Generate Code. The tool produces clean, production-ready code that you can copy directly into your project. The live preview area demonstrates the scroll behavior in real time so you can see exactly how your configuration feels before deploying it.
CSS vs JavaScript vs Lenis Smooth Scroll
The CSS scroll-behavior: smooth property is the simplest approach. It requires zero JavaScript and is supported by all modern browsers. However, it offers no control over duration or easing — the browser decides the animation curve. This is ideal for simple sites that just need basic smooth anchor scrolling without adding script weight.
Vanilla JavaScript smooth scroll gives you full control over duration, easing function, and scroll offset. You can define custom cubic-bezier curves for precise animation timing. The generated code handles anchor link clicks automatically and optionally adds a scroll-to-top button. This is the best choice when you need fine-grained control without external dependencies.
Lenis is a lightweight smooth scroll library used by many Awwwards-winning websites. It provides buttery-smooth inertial scrolling with configurable lerp (linear interpolation), wheel and touch multipliers, and direction control. Lenis hooks into the browser's native scroll events and applies momentum-based smoothing, creating a premium feel. The generated code includes the CDN link, initialization, animation frame loop, and cleanup function.
Choosing the Right Easing Function
Easing functions control the acceleration curve of your scroll animation. Linear easing moves at constant speed — mechanical and rarely desirable for UI animations. Ease-in starts slow and accelerates, creating a sense of building momentum. Ease-out starts fast and decelerates, which feels natural for scrolling since the page appears to settle into position. Ease-in-out combines both, starting slow, speeding up in the middle, and slowing down at the end — this is the most commonly used easing for smooth scroll because it feels organic and polished.
For advanced control, use the cubic-bezier option to define custom timing curves. The four values (x1, y1, x2, y2) represent control points on a bezier curve. Values outside 0-1 on the y-axis create overshoot effects where the scroll briefly goes past the target before settling. Tools like cubic-bezier.com can help you visualize and fine-tune your custom curve.
Performance Tips for Smooth Scrolling
Smooth scrolling can cause jank if not implemented carefully. When using JavaScript-based solutions, avoid triggering layout recalculations during the scroll animation. Use requestAnimationFrame for timing instead of setInterval or setTimeout. For Lenis, keep the lerp value between 0.05 and 0.15 for the best balance of smoothness and responsiveness. Higher lerp values feel snappier but lose the premium smooth feel. Lower values create more lag between input and visual response, which can frustrate users on content-heavy pages.
Consider disabling smooth scroll for users who prefer reduced motion by checking prefers-reduced-motion media query. This is an accessibility best practice. All three methods generated by this tool can be wrapped in a reduced-motion check to respect user preferences.