Home/Tools/Effects/Pattern Generator
Effects · Generator

Pattern Generator

Generate pure CSS background patterns — dots, grid, diagonal, checkerboard, and more.

Pattern Settings

4px
24px

Preview

Generated CSS
.patterned-bg {
  background: radial-gradient(circle, #94a3b8 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: #f8fafc;
}
100%
Free, no
sign-up needed
0
Code written
by hand
85+
CSS tools
in one place
<1s
Copy-ready
CSS instantly
What is this

What is the CSS Pattern Generator?

Generate CSS background patterns: dots, lines, grid, checkerboard, and diagonal stripes. Built entirely from CSS gradients - no image files.

Everything runs locally in your browser. Adjust the controls above, preview instantly, and copy clean, production-ready CSS — no account, no upload.

How to use

Using the CSS Pattern Generator

Everything lives in the panel at the top of this page. There is nothing to install — it all runs right here in your browser.

1

Select a pattern type

Choose dots, grid, diagonal stripes, checkerboard, cross, or zigzag. A live preview shows the pattern tiling.

2

Adjust size, spacing, and colour

Set the pattern element size, the background-size (controls tile repeat), and the foreground and background colours.

3

Copy the CSS

Click Copy to get the background-color, background-image, and background-size values together.

The output

What the generated code looks like

Clean, production-ready CSS — no vendor bloat, no unnecessary declarations.

styles.css
/* Dot grid pattern */
.dot-grid {
  background-color: #f8fafc;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Diagonal stripes */
.stripes {
  background: repeating-linear-gradient(
    -45deg,
    #f8fafc,
    #f8fafc 5px,
    #e2e8f0 5px,
    #e2e8f0 10px
  );
}

/* Graph paper */
.graph {
  background-color: white;
  background-image:
    linear-gradient(rgba(108,46,245,0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108,46,245,0.1) 1px, transparent 1px);
  background-size: 24px 24px;
}

CSS patterns are infinitely scalable, require no image files, and can be animated with background-position.

Copy & paste

Ready-to-use CSS patterns

Drop any of these straight into your project — no modifications needed.

Pattern that fades out

Layer a mask over the pattern so it dissolves towards the content — common behind hero sections.

styles.css
.hero-bg {
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent);
          mask-image: linear-gradient(to bottom, #000 40%, transparent);
}

Theme-aware pattern with custom properties

Drive the colours from variables so the same pattern works in light and dark mode.

styles.css
:root { --pat-bg: #ffffff; --pat-fg: #e2e8f0; }
@media (prefers-color-scheme: dark) { :root { --pat-bg: #0b1220; --pat-fg: #1e293b; } }

.checker {
  background-color: var(--pat-bg);
  background-image: conic-gradient(var(--pat-fg) 25%, transparent 0 50%, var(--pat-fg) 0 75%, transparent 0);
  background-size: 32px 32px;
}
Common mistakes & fixes

Common mistakes & how to fix them

A few habits trip people up. Here is what to watch for — and the exact fix.

Pattern on the element that holds text

Busy patterns directly behind paragraphs reduce readability and contrast.

Fix: Put the pattern on a wrapper or ::before layer and give text a solid or semi-opaque panel.

Sub-pixel tile sizes

A background-size such as 13.5px makes lines blur or vary in thickness between tiles.

Fix: Use whole-pixel tile sizes and line widths so every repeat renders identically.

Pro tips

Pro tips for better results

★

background-size controls the tile repeat frequency

A smaller background-size repeats the pattern more densely. A larger one spaces it out. This value is independent of the dot or line size within the gradient.

★

Patterns can be animated by changing background-position

animation: slide 2s linear infinite; @keyframes slide { to { background-position: 24px 24px; } } creates a moving pattern.

★

Keep pattern contrast low for backgrounds

Patterns behind content should be subtle (5-15% opacity difference from background). High-contrast patterns compete with the content sitting on top.

FAQ

Frequently asked questions

Patterns built from linear-gradient, radial-gradient and repeating gradients work in every current browser. conic-gradient (used for some checkerboards) is supported in Chrome, Edge, Firefox and Safari 12.1+. mask-image still needs the -webkit- prefix in some Chromium and Safari versions.
Gradient patterns are drawn by the browser instead of downloaded, so they add no network weight. Very large, constantly animated patterns can cost paint time; keep animated patterns small or use transform on a pseudo-element.
CSS patterns are infinitely scalable, have no file size, render crisply on retina displays, and can be animated. Image textures offer more complexity (photography, hand-drawn textures) that CSS cannot replicate. Use CSS for geometric patterns, images for organic textures.
No. Everything runs in your browser. Nothing is sent to a server.

From the blog

Read more →