CSS line-clamp generator
Generate a CSS rule that truncates text after a set number of lines, with an ellipsis or a fade.
CSS line-clamp generator
Card titles, product descriptions and comment previews all need the same trick eventually: show a few lines of text and cut the rest off cleanly instead of letting a long paragraph blow out the layout. This generator writes that CSS rule for you, ready to paste into a stylesheet as a ".line-clamp" class.
Choose single-line mode for a one-line truncation — the classic "overflow: hidden; text-overflow: ellipsis; white-space: nowrap" combination used for titles and table cells — or multi-line mode, which uses "-webkit-line-clamp" to cut off after however many lines you set, honoring the line-height you choose. Turn on the fade option to soften the last line into the background with a gradient instead of a hard ellipsis, which reads better over an image or a colored card. The fallback option adds an "@supports" block so browsers without line-clamp support still get a sensible max-height cutoff rather than an unclipped wall of text, and the Tailwind option appends the matching utility class ("truncate" or "line-clamp-N") as a comment so you don't have to look it up.
Type or paste a sentence into the preview field and the tool estimates how your text would break across the chosen number of lines, so you can sanity-check the line count before you commit to a design. The estimate is based on an average reading-line length rather than measuring real fonts and containers — it's a guide for picking a sensible line count, not a pixel-accurate render.
Everything runs locally in your browser: the CSS is generated as you type, nothing is uploaded anywhere, and you can copy the result, download it as a .txt file, or send it straight into another tool's input to keep working on it.