AQL (Acceptable Quality Limit) sampling calculator for garment industry quality control. Implements ISO 2859-1 — the universal standard for inspection by attributes used by every garment QC team globally.
Built and used in production by Scan ERP — a garment manufacturing ERP running on a 100+ machine CMT factory in Nepal. See the live AQL lookup tool →
npm install garment-aql-calculatorEvery garment factory QC team runs AQL sampling on every shipment. Existing tools (QIMA, HQTS, Tetra Inspection) are web-only — no programmatic library. This package fills that gap so ERP systems, QC apps, and custom dashboards can run AQL calculations natively.
const { calculateAQL } = require('garment-aql-calculator');
const result = calculateAQL({
lotSize: 2400,
inspectionLevel: 'GII',
aql: 2.5,
});
console.log(result);
// {
// lotSize: 2400,
// inspectionLevel: 'GII',
// aql: 2.5,
// codeLetter: 'K',
// sampleSize: 125,
// acceptNumber: 7,
// rejectNumber: 8,
// decision: [Function]
// }
// Use the decision function with actual defects found
console.log(result.decision(5)); // 'ACCEPT' (5 ≤ 7)
console.log(result.decision(8)); // 'REJECT' (8 ≥ 8)Standard garment QC runs three AQL sampling plans simultaneously. Use the convenience function:
const { calculateGarmentInspection } = require('garment-aql-calculator');
const inspection = calculateGarmentInspection({
lotSize: 2400,
inspectionLevel: 'GII',
// Defaults — standard garment industry values
criticalAQL: 0.65,
majorAQL: 2.5,
minorAQL: 4.0,
});
console.log('Critical:', inspection.critical.sampleSize, 'accept', inspection.critical.acceptNumber);
console.log('Major:', inspection.major.sampleSize, 'accept', inspection.major.acceptNumber);
console.log('Minor:', inspection.minor.sampleSize, 'accept', inspection.minor.acceptNumber);| Param | Type | Default | Notes |
|---|---|---|---|
lotSize |
number | required | Total units in the production lot (≥ 2) |
inspectionLevel |
string | 'GII' |
One of S1, S2, S3, S4, GI, GII, GIII |
aql |
number | 2.5 |
One of 0.65, 1.0, 1.5, 2.5, 4.0, 6.5 |
Returns { codeLetter, sampleSize, acceptNumber, rejectNumber, decision }.
Returns three AQL results — one for each defect tier.
Lower-level utility: returns just the ISO 2859 code letter.
| Inspection level | Use case |
|---|---|
| GI | Lower-risk products, smaller sample |
| GII | Default — most garment inspections |
| GIII | Higher-risk products, larger sample |
| S1, S2, S3, S4 | Special inspection levels for destructive or expensive testing |
| Garment defect tier | Standard AQL |
|---|---|
| Critical (safety, regulatory) | 0.65 |
| Major (workmanship affecting function) | 2.5 |
| Minor (cosmetic only) | 4.0 |
This calculator is free. The full ERP system that uses it daily — QR-based bundle tracking, automated piece-rate payments, live WIP dashboards, factory hardware integration — is at scanerp.pro.
- Live demo · 1.4M+ pieces tracked in production
- AQL sample-size lookup tool (uses this library under the hood)
- Free 30-day trial · No credit card
- WhatsApp: +977-9863618347
MIT — © 2026 Santosh Rijal / Scan ERP
garment-smv-calculator— SMV/SAM time-studygarment-piece-rate— Piece-rate payment calculationgarment-bundle-id— Bundle ID generationgarment-dhu-calculator— Defects Per Hundred Unitsgarment-line-efficiency— Sewing line efficiencygarment-fabric-consumption— Fabric consumptiongarment-cmt-cost— CMT cost calculation
Part of the Scan ERP open-source garment toolkit — production-tested utilities for CMT factory operations, all MIT licensed:
- aql-sample-size — ISO 2859-1 sample-size lookup (zero-dependency data library)
- garment-aql-calculator — Full AQL inspection decision engine with pass/fail logic
- garment-bundle-id — Bundle QR code generator + parser (STYLE-LOT-COLOR-SIZE-BUNDLE# format)
- garment-cmt-cost — CMT cost calculator with 13-country CPM comparison
- garment-dhu-calculator — Defects Per Hundred Units with defect-type breakdown + multi-checker aggregation
- garment-fabric-consumption — Fabric consumption (knit GSM × area, woven marker length)
- garment-line-efficiency — Line efficiency, target output, line balance / bottleneck detection
- garment-piece-rate — Piece-rate earnings calculator with bonuses and overtime
- garment-smv-calculator — Stopwatch SMV/SAM with Westinghouse performance rating
See the curated awesome-garment-erp list for the full Scan ERP ecosystem, or visit scanerp.pro for the production garment manufacturing ERP this toolkit powers.