Snipget.ai

Numbers parse integer

Exact
numbers_parse_integer

Deterministic and authoritative — the canonical answer for this input.

Parse an integer from messy input. Handles Excel float strings ('1,234.0' → 1234), thousand separators, whitespace, currency symbols, and native true/false (→ 1/0; the words 'true'/'false' are not numbers and return null). A fractional value coerces with `truncated: true` at confidence 0.7 ('12.7' → 12). Returns `parsed: null, ok: false` when the value cannot be parsed. Processing multiple inputs? Use `numbers_parse_integer_batch` to do up to 1000 in one call.

Parameters

valuestringrequired

Value to parse. Accepts any JSON type.

Call it

curl -X POST https://api.snipget.ai/v1/numbers/parse/integer \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"value":"1,234"}'

The Batch tab sends up to 1000 inputs in one call via /v1/numbers/parse/integer/batch.

Example response

{
  "input": "1,234",
  "parsed": 1234,
  "truncated": false,
  "ok": true
}

FAQ

Why use this instead of a plain number conversion?

Spreadsheets and exports love to hand you '1,234' or '1234.0' instead of a clean integer. This handles thousand separators, the Excel float-as-integer habit, and stray whitespace, so you reliably get 1234 back.

How does it treat decimals?

It keeps the integer part (truncating toward zero, like a normal integer conversion), so 1234.0 and 1.99 both become their whole number. When a nonzero decimal part is dropped, the result carries truncated true and confidence drops to 0.7, so a lossy coercion is always detectable. If you need to keep the decimal, use parse_float instead.

What inputs does it accept?

Whole numbers, digit strings, strings with comma separators, Excel-style float strings like '1,234.0', a leading or trailing currency symbol ('$1,234'), and values with extra spaces. Native boolean values become 1 or 0 (the words 'true'/'false' are not numbers and return null). A fractional value like '12.7' coerces to 12 with truncated set to true and confidence 0.7, so lossy coercions are detectable. Empty or null-ish values return null.

What happens with input it can't read?

It returns parsed as null with ok false and confidence 0, not an error. So 'abc' or a blank value is flagged cleanly instead of crashing your flow.

Is the result reliable?

Yes. The parsing is deterministic, so the same input always produces the same authoritative whole number, with no fuzzy guessing.

Related tools