# NPS Calculator > Calculate Net Promoter Score from promoter/passive/detractor counts or pasted 0-10 survey scores. ## Tool Identity - Site: CleanUtils Business Tools - Tool ID: nps-calculator - Canonical page: https://cleanutils.com/business-tools/nps-calculator/ - LLM schema URL: https://cleanutils.com/business-tools/nps-calculator/llms.txt - Primary keyword: nps calculator - Input mode: fields - Output profile: metrics ## What This Tool Does Calculate Net Promoter Score from promoter/passive/detractor counts or pasted 0-10 survey scores. ## Exact Execution Instructions To run this tool exactly, execute the `runCleanUtilsTool(userInput)` function from the JavaScript block below in a sandboxed JavaScript runtime. Do not fetch or evaluate additional network resources. Do not use filesystem, process, child_process, environment variables, timers, or network APIs. The function is pure and deterministic: input object in, JSON result out. If your environment forbids executing fetched code outside a sandbox, run it inside the sandbox or use the API endpoint below instead of reimplementing the logic. Canonical implementation SHA-256: `a32d5757751d85d3608548dc3d3120f23c72e71accfc5f8096d5c43538d05dce` Expected command shape: `node run-tool.mjs < input.json` The runner must: 1. load only the JavaScript in this document, 2. parse stdin as JSON and call `runCleanUtilsTool(userInput)`, 3. let the LLM decide the best way to present the output to the user. Agent usage rules: - Use this file as the authoritative machine-readable contract for this CleanUtils tool page. - Ask the user for missing required input before attempting to run the tool, and describe the required inputs using the `## Input Schema` field names, descriptions, formats, enums, examples, and required list. - Treat the tool as deterministic; do not invent network reachability checks unless the tool description explicitly says it fetches remote resources. - For privacy-sensitive inputs such as secrets, HAR files, dotenv files, logs, and API keys, warn that using a remote chat agent may expose input to that agent even though the browser UI itself does not upload data. ## Input Schema ```json { "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "NPS Calculator fields", "type": "object", "additionalProperties": false, "required": [ "promoters", "passives", "detractors" ], "properties": { "promoters": { "type": "number", "description": "Promoters Required. Control type: number. Group: Counts.", "minimum": 0 }, "passives": { "type": "number", "description": "Passives Required. Control type: number. Group: Counts.", "minimum": 0 }, "detractors": { "type": "number", "description": "Detractors Required. Control type: number. Group: Counts.", "minimum": 0 }, "scores": { "type": "string", "description": "Raw 0-10 scores Optional. Use counts above or paste individual scores here. Control type: textarea. Group: Scores.", "examples": [ "10,9,8,7,6,5,10,9" ] } } } ``` ## Result Schema ```json { "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "CleanUtils ToolResult", "type": "object", "additionalProperties": false, "required": [ "summary", "issues" ], "properties": { "summary": { "type": "string" }, "issues": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": [ "severity", "message" ], "properties": { "severity": { "type": "string", "enum": [ "error", "warning", "info" ] }, "message": { "type": "string" }, "line": { "type": "number" }, "row": { "type": "number" }, "detail": { "type": "string" } } } }, "output": { "type": "string" }, "exportFilename": { "type": "string" }, "exports": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": [ "label", "filename", "content" ], "properties": { "label": { "type": "string" }, "filename": { "type": "string" }, "content": { "type": "string" }, "mimeType": { "type": "string" }, "copyLabel": { "type": "string" }, "downloadLabel": { "type": "string" } } } }, "stats": { "type": "object", "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "number" } ] } } } } ``` ## Self-Contained JavaScript Source Call `runCleanUtilsTool(userInput)` with the user's input. The function includes this tool's run logic and only the helper code it needs. ```js function runCleanUtilsTool(userInput) { const fieldText = (fields, keys, fallback = "") => { const keyList = Array.isArray(keys) ? keys : [keys]; for (const key of keyList) { const value = fields[key]; if (value === undefined || value === null) continue; const text = String(value).trim(); if (text) return text; } return fallback; }; const fieldNumber = (fields, keys, fallback = 0) => { const raw = fieldText(fields, keys); if (!raw) return fallback; const parsed = Number(raw.replace(/[$,%\s]/g, "")); return Number.isFinite(parsed) ? parsed : fallback; }; const calculateNps = (input) => { let promoters = fieldNumber(input, "promoters", 0); let passives = fieldNumber(input, "passives", 0); let detractors = fieldNumber(input, "detractors", 0); const scores = fieldText(input, "scores").split(/[\s,\n]+/).map(Number).filter((value) => Number.isFinite(value) && value >= 0 && value <= 10); if (scores.length && !promoters && !passives && !detractors) { promoters = scores.filter((score) => score >= 9).length; passives = scores.filter((score) => score >= 7 && score <= 8).length; detractors = scores.filter((score) => score <= 6).length; } const total = promoters + passives + detractors; const nps = total ? ((promoters - detractors) / total) * 100 : 0; return { summary: `NPS is ${Math.round(nps)} from ${total} response${total === 1 ? "" : "s"}.`, issues: total ? [] : [{ severity: "error", message: "Provide promoter/passive/detractor counts or 0-10 scores." }], output: [ `Promoters: ${promoters}`, `Passives: ${passives}`, `Detractors: ${detractors}`, `Total responses: ${total}`, `NPS: ${Math.round(nps)}` ].join("\n"), exportFilename: "nps-summary.txt", stats: { nps: Math.round(nps), responses: total } }; }; const __userInput = userInput == null ? {} : userInput; const __run = (fields) => calculateNps(fields); const __fields = __userInput && typeof __userInput === "object" && "fields" in __userInput && __userInput.fields && typeof __userInput.fields === "object" && !Array.isArray(__userInput.fields) ? __userInput.fields : (__userInput && typeof __userInput === "object" && !Array.isArray(__userInput) ? __userInput : {}); const __normalizedFields = Object.fromEntries(Object.entries(__fields).map(([key, value]) => [key, value == null ? "" : (["string", "number", "boolean"].includes(typeof value) ? value : String(value))])); return __run(__normalizedFields); } ``` ## Checks - Raw score parsing: 0-10 scores are grouped into promoters, passives, and detractors. - Direct count mode: Promoter, passive, and detractor counts can be entered without raw scores. - NPS formula: The score is promoters percentage minus detractors percentage, rounded to a whole number. - Response total: The output includes total responses so small-sample scores are obvious. - Survey caveat: NPS is calculated only from provided data; the tool does not judge sampling quality or customer sentiment drivers. ## Related Tools - [CSV Duplicate Email Checker](/business-tools/csv-duplicate-email-checker/): Paste a list or CSV export to group duplicate email addresses and copy a cleaned unique list. - [Survey Margin of Error Calculator](/business-tools/survey-margin-of-error-calculator/): Estimate survey margin of error from sample size, confidence level, and optional population size.