SVG Pattern Generator
Pick one of six tile types, set its color, spacing, stroke width, and opacity, and this tool builds a small SVG tile and tiles it across a 400 px tall preview. The CSS output is a .pattern-background rule with the tile inlined as a base64 data URI, so you can paste it into a stylesheet without hosting a separate image file.
How to make a pattern
- Choose a Pattern Type: Micro Dots, Crosshatch, Zig-Zag Lines, Grid, Diagonal Stripes, or Hexagons.
- Pick a Pattern Color, then set Spacing (5 to 50 px, the tile size), Stroke Width (1 to 5 px), and Opacity (0.1 to 1).
- Click Generate Pattern. The sliders do not redraw on their own, so click again after each change.
- Click Copy CSS for the rule shown under CSS Code, or Download SVG for the bare tile as a
pattern-file.
Tile size, edges, and data URIs
A repeating background is one small tile drawn over and over, so the Spacing value is literally the tile's width and height in pixels. Hexagons are the exception: the tile is spacing wide and about 1.73 times as tall, with an offset second row, because a honeycomb does not repeat on a square grid.
Lines that sit exactly on a tile edge, such as the Grid option's top and left strokes, are cut in half by the tile boundary, so they render thinner than the Stroke Width you chose. Diagonal Stripes and Crosshatch show the same problem in miniature, as small notches where a stroke crosses a tile corner. The data URI is base64 of the raw SVG, which is about a third larger than the text it encodes. For a tile this small that does not matter, and it saves a request. For anything large, link a real file. The CSS uses background-repeat: repeat and sets background-size to the tile dimensions.