Stitch gauge from swatch calculator
Counting 22 stitches and 30 rows over 4 inches gives a gauge of 5.5 stitches and 7.5 rows per inch. Enter what you counted on your blocked swatch and get the density per unit, per 4 and per 10. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Stitches count
- 22
- Measured width
- 4
- Rows count
- 30
- Measured length
- 4
- Stitch gauge
- 5.5
- Row gauge
- 7.5
- Stitches per unit
- 5.5
- Rows per unit
- 7.5
A stitch gauge from swatch calculator turns the four numbers you actually measure on a blocked knitting sample into the density every pattern assumes: stitches per unit of width and rows per unit of length. Enter how many stitches you counted across a measured width, how many rows you counted along a measured length, and keep width and length in the same unit—inches, centimetres, or any other consistent scale. The tool divides counts by measurements, rounds floats to stable fixed decimals, and also reports the same density scaled to four-unit and ten-unit windows so you can match US four-inch quotes and metric ten-centimetre quotes without a second calculation. Sweater fronts, scarves, sock legs, and baby blankets all need that measured gauge before you trust cast-on math or compare against a published pattern.
What swatch gauge means and how to measure it
Knitting gauge from a swatch is the density of your fabric after you wash and block a small sample the way you will treat the finished piece. You cast on more stitches than you need for the measurement window, work more rows than the window height, then lay the fabric flat and count whole stitches across a known width and whole rows along a known length.
Typical teaching windows are four inches by four inches or ten centimetres by ten centimetres, but any consistent pair of measurements works: twenty-two stitches across four inches is five and a half stitches per inch; thirty rows across ten centimetres is three rows per centimetre. Teachers and shop classes care about the non-positive rejection as much as the happy path: a zero width or zero stitch count is not a real swatch measurement, and silently clamping it would invent densities that cannot be knit.
Prefer counting in the middle of the swatch, away from edge columns and cast-on or bind-off rows, and always measure after the same block you plan for the garment. The check path recomputes both quotients with the same fixed rounding used for published fields, so a successful response always ships with steps you can assert in tests, worksheets, or a project notebook before you commit yarn or resize a pattern.
What you can do with it
Convert a blocked swatch into SPI and RPI
Crafters count stitches and rows on a four-inch window, enter the counts and measured sizes, and get stitches and rows per unit plus per-four and per-ten reports for pattern notes.
FAQ
Should I measure in inches or centimetres?
Either works as long as width and length use the same unit. The result is stitches and rows per that unit. Use the per-4 fields for US four-inch quotes and the per-10 fields for metric ten-centimetre quotes.
Does this tell me how many stitches to cast on?
No. This capability only computes gauge from a swatch.
Is the stitch gauge from swatch calculator free?
The browser tool is free and runs locally.
What is my gauge if I count 22 stitches and 30 rows over 4 inches?
Your gauge is 5.5 stitches and 7.5 rows per inch. Over 10 inches that would be 55 stitches and 75 rows, which helps when you compare it with a pattern that quotes a different window.
Where on the swatch should I count?
Count in the middle, away from the edge columns and the cast-on and bind-off rows, and only after washing and blocking the sample the way you will treat the finished piece.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/hobby/craft-knit-gauge-from-swatch \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"stitches_count":22,"measured_width":4,"rows_count":30,"measured_length":4}'const res = await fetch("https://api.kit.forhosting.com/hobby/craft-knit-gauge-from-swatch", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"stitches_count": 22,
"measured_width": 4,
"rows_count": 30,
"measured_length": 4
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/hobby/craft-knit-gauge-from-swatch",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"stitches_count": 22,
"measured_width": 4,
"rows_count": 30,
"measured_length": 4
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/hobby/craft-knit-gauge-from-swatch", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"stitches_count":22,"measured_width":4,"rows_count":30,"measured_length":4}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"stitches_count":22,"measured_width":4,"rows_count":30,"measured_length":4}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/hobby/craft-knit-gauge-from-swatch", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"stitches_count": 22,
"measured_width": 4,
"rows_count": 30,
"measured_length": 4
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "hobby.craft_knit_gauge_from_swatch",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Zero or negative stitch counts, row counts, or measured sizes are rejected with a clear invalid_input error, because a non-positive count or length cannot define fabric density.
What swatch gauge means and how to measure it
This calculator never invents units; it only divides stitches_count by measured_width and rows_count by measured_length, so if you measured in inches your stitch_gauge is stitches per inch, and if you measured in centimetres it is stitches per centimetre.
How to call the API and what comes back
Every field must be strictly positive; values at or below one times ten to the minus fifteen are treated as non-positive and rejected, which covers the required zero and negative measurement errors as well as empty counts. Send a JSON body with four required finite positive numbers: stitches_count (aliases stitches, stitch_count, sts, sts_count, stitch_number), measured_width (aliases width, swatch_width, w, width_measured), rows_count (aliases rows, row_count, rws, row_number), and measured_length (aliases length, swatch_length, height, l, length_measured). Absolute values must stay within the published limit of one trillion so intermediate quotients remain finite in IEEE double precision on the Worker and in the browser. On success the response echoes rounded inputs, sets stitch_gauge and stitches_per_unit to the same rounded density, sets row_gauge and rows_per_unit to the same row density, adds stitches_per_4, rows_per_4, stitches_per_10, and rows_per_10 as scaled reports for common pattern quote windows, formula to a compact summary of the equations, message to a short English summary, and steps to an ordered array of substitution lines. Failed validation—missing fields, non-finite numbers, values outside absolute limits, or non-positive counts or measurements—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price.
Practical tips, units, and how this differs from cast-on tools
Measure gauge after the same wash and block you plan for the finished fabric; wet gauge and dry gauge often differ, and this tool will faithfully scale whatever counts and lengths you feed it. Prefer a full four-inch or ten-centimetre window rather than two stitches across half an inch when you can, because small counting or ruler errors amplify when you divide and later multiply by a wide sweater front. Prefer sending numbers rather than pre-formatted strings when you control the client; string numbers are accepted only when they match a strict finite numeric pattern. When teaching, pair examples: twenty-two stitches over four inches and thirty rows over four inches yields five point five stitches and seven point five rows per unit; twenty-two stitches over ten centimetres and thirty rows over ten centimetres yields two point two stitches and three rows per centimetre; and measured_width zero demonstrates the hard invalid_input path on non-positive measurement. This landing targets people searching for a stitch gauge from swatch calculator, stitches and rows per inch from a sample, or how to calculate knitting gauge from measurements; it is not a cast-on planner, not a yarn-yardage estimator, and not a needle-size recommender. Prefer this capability when you have just finished measuring a physical swatch and need density first; once you know stitch_gauge and row_gauge, feed them with target width and length into a cast-on gauge calculator such as hobby.knitting_gauge to plan stitches to cast on and rows to knit. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when learners deliberately set measured_width to zero. Round-trip checks are easy: recompute stitches_count divided by measured_width by hand and confirm it equals stitch_gauge within the same twelve-decimal rounding, and confirm that stitch_gauge times four equals stitches_per_4.
Integration use cases
Match a published pattern gauge quote
Designers measure their own yarn and needles, compute density, and compare stitches_per_4 or stitches_per_10 against the pattern’s four-inch or ten-centimetre gauge before resizing.
Fixtures for knitting apps and classes
Hobby apps and education tools generate known-good gauge pairs plus deliberate zero-width rejections for deterministic regression tests and worksheet answer keys.
Technical questions
How do you calculate stitch gauge from a swatch?
Count the stitches across a measured width, then divide stitches_count by measured_width. Row gauge is rows_count divided by measured_length in the same unit. This tool returns both densities plus scaled per-4 and per-10 values.
What happens when measured_width or stitches_count is zero or negative?
The request is rejected with invalid_input. Non-positive counts or measurements cannot define a fabric density and would not produce a meaningful gauge.