ForHosting KIT · Health & fitness

Urine anion gap calculator

Urine sodium 40, potassium 20 and chloride 80 mEq/L give a urine anion gap of −20, the classic classroom pattern of ammonium being excreted after gut losses. Three spot urine values, one subtraction. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Urine sodium
40
Urine potassium
20
Urine chloride
80
You get
Urine anion gap
-20 mEq/L
Gap sign
negative

The urine anion gap estimates unmeasured urine cations—chiefly ammonium—from three spot urine electrolytes: sodium, potassium, and chloride. Acid-base courses use that leftover when a hyperchloremic metabolic acidosis needs a renal versus gastrointestinal teaching split, and software teams need the same arithmetic in every client without copying a spreadsheet formula.

What the urine anion gap measures and which inputs you need

The urine anion gap is a bedside accounting identity used in acid-base teaching to estimate whether the kidney is excreting ammonium when a learner is reviewing a hyperchloremic, normal serum anion-gap metabolic acidosis. Electroneutrality in urine requires that measured cations plus unmeasured cations equal measured anions plus unmeasured anions. The two cations that every laboratory reports on a spot urine electrolyte panel are sodium and potassium; the measured anion is chloride.

Ammonium is the main unmeasured cation of interest during acidosis, so the leftover after sodium plus potassium minus chloride tracks, with opposite sign, how much ammonium is present. In symbols the urine anion gap equals urine sodium plus urine potassium minus urine chloride, all in milliequivalents per litre, which for monovalent ions is the same as millimoles per litre. A typical teaching panel of urine sodium forty, urine potassium twenty, and urine chloride eighty yields a gap of negative twenty, the classic gastrointestinal-loss classroom example.

A panel of urine sodium eighty, urine potassium forty, and urine chloride fifty yields a gap of positive seventy, the classic low-ammonium renal-tubular-acidosis classroom example. Practical bounds keep classroom and consumer inputs sane: each electrolyte from zero through five hundred milliequivalents per litre.

Health education apps and worksheets

Apps show learners how a negative leftover tracks extra urinary ammonium in GI-loss examples without re-coding Na + K − Cl on every client.

How is the urine anion gap calculated?

Urine anion gap = urine sodium + urine potassium − urine chloride, all in mEq/L.

What happens if an electrolyte concentration is negative?

Negative urine sodium, potassium, or chloride values are rejected and not charged.

Is a negative urine anion gap the same as a serum anion gap?

No. The serum anion gap is sodium minus chloride minus bicarbonate. The urine anion gap is urine sodium plus urine potassium minus urine chloride. They answer different teaching questions and use different samples.

What does the urine anion gap calculator cost?

The browser tool runs free on your device.

What does a negative urine anion gap suggest?

A negative gap means more unmeasured cations, chiefly ammonium, so the kidney is excreting acid; that is the classic gut-loss teaching example. A clearly positive gap points to little ammonium, the classic renal tubular acidosis example.

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.

POSThttps://api.kit.forhosting.com/health/urine-anion-gap

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.

curl -X POST https://api.kit.forhosting.com/health/urine-anion-gap \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"urine_sodium":40,"urine_potassium":20,"urine_chloride":80}'
{
  "urine_sodium": 40,
  "urine_potassium": 20,
  "urine_chloride": 80
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "health.urine_anion_gap",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

This capability accepts the three concentrations in milliequivalents per litre, returns urine_anion_gap as sodium plus potassium minus chloride, and echoes the inputs with a short formula string you can pin in tests. Any negative electrolyte concentration fails with invalid_input and is never billed.

What the urine anion gap measures and which inputs you need

Send required fields urine_sodium, urine_potassium, and urine_chloride as finite numbers; documented aliases such as una, uk, and ucl are accepted. Any negative concentration fails with invalid_input because a negative urine electrolyte is not a valid panel for this calculator. Identical inputs always yield identical JSON because the path is pure arithmetic with no network, no model, no random seed, and no wall clock.

Reading urine_anion_gap, gap_sign, and the response fields

Numeric strings are accepted for each field so a form that collects whole numbers still works. On success the response echoes urine_sodium, urine_potassium, and urine_chloride with stable rounding, reports urine_anion_gap as sodium plus potassium minus chloride in milliequivalents per litre, and sets unit to mEq/L so clients never guess the scale. The gap_sign field is positive when the gap is greater than zero, negative when the gap is less than zero, and zero when the three concentrations cancel exactly, which lets a worksheet colour a teaching band without re-implementing the comparison. The formula string restates UAG equals Na plus K minus Cl, and method is always urine_anion_gap so downstream code can branch without sniffing shapes. Use urine_anion_gap alone when you only need the number for a lab notebook; use gap_sign when you are teaching why a negative leftover is the usual classroom marker for extra urinary ammonium and a positive leftover is the usual marker for low ammonium. Missing required electrolytes, non-finite values, out-of-range readings, and any negative sodium, potassium, or chloride all fail with invalid_input and are not charged. Do not confuse this endpoint with a serum anion gap calculator that subtracts chloride and bicarbonate from sodium, with a TTKG calculator that needs urine and serum potassium plus osmolality, or with a full acid-base interpretation engine—those are different search intents and different contracts.

API usage, pricing, product workflows, and practical limits

Call the free in-browser urine anion gap calculator for classroom demos, nursing homework checks, and quick personal learning without reimplementing the identity in every spreadsheet. Prefer consistent milliequivalent units for monovalent ions; if your UI only collects whole numbers, send integers and the engine still accepts numeric strings. Keep expectations educational: this is a calculation and learning tool, not a diagnostic medical device, and people with symptoms, known acid-base disorders, kidney disease, or diarrhea should follow professional medical advice rather than any single automated number alone. Send a JSON body with required urine_sodium, urine_potassium, and urine_chloride values. Use the prepaid API when a health SaaS, electronic worksheet, simulation lab, tutoring platform, or school LMS needs a stable contract under KIT balance at $0.002 per successful item; validation failures never consume balance after the engine rejects the request. Pair this endpoint with your own laboratory units and teaching workflow—confirm that the panel is a spot urine electrolyte set in milliequivalents per litre, not a twenty-four-hour excretion, and that chloride is the measured anion rather than a calculated value—then store urine_anion_gap alongside the raw electrolytes for dashboards and export columns for sodium, potassium, chloride, and the gap. Authors shipping SDKs can map urine_anion_gap and gap_sign into tables and step-by-step teaching cards that show the formula string. Negative electrolyte concentrations are rejected as invalid_input, matching the product contract, and values above five hundred milliequivalents per litre are likewise rejected as out of the practical teaching range.

Nursing and medical-school acid-base homework

Students submit a spot urine Na, K, and Cl panel and pin expected urine_anion_gap and gap_sign JSON in automated checkers with deterministic outputs.

Simulation labs and SaaS backends

Server pipelines that already store urine electrolyte panels call a prepaid endpoint for the gap instead of duplicating the identity in every language.

What do positive and negative gap_sign values mean in teaching?

gap_sign is arithmetic, not a diagnosis. Textbooks often treat a negative leftover as extra urinary ammonium (GI bicarbonate-loss examples) and a positive leftover as low ammonium (renal-tubular-acidosis examples). This calculator only reports the sign of Na + K − Cl.

Read the full KIT documentation →