:nth-child An+B Evaluator
Paste a CSS selector like ":nth-child(2n+1)" or ":nth-of-type(-n+3)" and see exactly which child indices it selects. The tool parses the An+B microsyntax from the CSS Values spec into its (A, B) coefficients, covering the keywords even and odd as well as forms like n, 2n, -n+3, 0n+5 and a bare integer such as 3. It validates the grammar and reports parse errors, then for any count of children N it lists the matching indices (the children selected by the formula), checks whether a specific 1-based index matches, and shows the first several matches. This is useful when you want to know, for example, that :nth-child(3n+1) selects the 1st, 4th, 7th, ... children, or that :nth-of-type(-n+3) selects just the first three of a kind. Everything runs on-device.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Drop a file here, or browse
Accepts: .css,.txt,.html,text/plain,text/css
Files stay on your device.
Ctrl+V to paste an image
Text is processed on this device. If a file is selected, the file is used instead.
Options
Drop a file above to begin
Your file are processed on this device and never uploaded.
How it works
What it evaluates
Paste a CSS selector like ":nth-child(2n+1)" or ":nth-of-type(-n+3)" and the tool parses the An+B microsyntax from the CSS Values spec into its (A, B) coefficients, covering the keywords even and odd as well as forms like n, 2n, -n+3, 0n+5 and a bare integer such as 3. It validates the grammar and reports parse errors, so you know immediately whether the selector is well formed.
Seeing which children match
For any count of children N it lists the matching indices — the children selected by the formula — checks whether a specific 1-based index matches, and shows the first several matches. That makes it easy to confirm that :nth-child(3n+1) selects the 1st, 4th, 7th, … children, or that :nth-of-type(-n+3) selects just the first three of a kind.
An+B in plain terms
The A is the cycle length and B is the offset: indices B, A+B, 2A+B, … are selected, stopping when the list runs out. even and odd are the common special cases, and a bare integer like 5 selects exactly the 5th child. Understanding the two coefficients is all you need to predict the selection without building a test list.
Running on-device
Everything is parsed and evaluated entirely in this tab, so the selector is never sent anywhere and the tool works fully offline. You can vary the children count and a single test index to explore the same formula against different list sizes.
Questions
What is the difference between :nth-child and :nth-of-type?
:nth-child counts all sibling children, while :nth-of-type counts only siblings of the same element type. The tool evaluates the same An+B coefficients for either pseudo-class, so you can compare how the two select against the same list.
What do the A and B in An+B mean?
A is the cycle length and B is the offset: the formula selects indices B, A+B, 2A+B and so on, stopping at the last child. even is 2n, odd is 2n+1, and a bare integer such as 3 is just the constant 3.
Can I test a specific index?
Yes. The index option takes a single 1-based child index and the tool reports whether that child is selected by the formula, alongside the full list of matches for the current children count.
Is the selector sent anywhere?
No. The selector is parsed and evaluated entirely on-device; nothing is transmitted and the tool works fully offline.
Related tools
See categoryCSS Unit Converter
Convert between px, rem, em, pt, pc, in, cm, mm and % for CSS lengths.
CSS Grid Generator
Generate CSS Grid layout declarations for tracks, gaps, alignment, and named areas.
Regex Explainer
Break a regular expression into tokens with a plain-English explanation of each piece.
.editorconfig Generator
Generate an .editorconfig with your indentation, line-ending and charset settings.