Count Number Occurrences
Count how many times each number appears in your text. Analyze frequency, find duplicates, and export occurrence statistics instantly.
| # | Number | Count | Frequency | Bar |
|---|
About
Extracting and counting numeric values from unstructured text is a prerequisite for data validation, audit trails, and statistical pre-processing. A miscount in financial reconciliation or inventory data can cascade into material discrepancies. This tool parses arbitrary text using pattern matching to isolate every numeric token - integers, decimals, and negatives - then aggregates occurrences into a frequency distribution. It handles edge cases such as leading zeros (007 vs 7), negative values (−3.5), and decimal precision. The extraction regex targets tokens matching n = match(/−?\d+(\.\d+)?/g), ensuring standalone numbers within sentences, CSV rows, or log files are captured without false positives from version strings or dates.
Accuracy depends on input formatting. Numbers embedded in words (e.g., "abc123def") will be extracted as 123. Phone numbers and zip codes will be tokenized as individual digit groups. This tool approximates general-purpose numeric extraction; domain-specific parsing (timestamps, IP addresses) requires dedicated validators. For datasets exceeding 100,000 characters, processing is chunked to prevent browser thread blocking.
Formulas
The occurrence count for each distinct number ni in the extracted set S is computed as:
The normalization function strips leading zeros and trailing decimal zeros:
Relative frequency (percentage) for each number:
Where S is the complete set of extracted numeric tokens, |S| is the total count of all extracted numbers, and ni represents each unique normalized number.
Reference Data
| Input Pattern | Extracted Numbers | Count | Notes |
|---|---|---|---|
| "Score: 42, 42, 85" | 42, 42, 85 | 3 | Duplicates counted separately |
| "Temperature: -5.3°C" | −5.3 | 1 | Negative decimals supported |
| "Version 3.14.159" | 3.14, .159 → 3, 14, 159 | 3 | Dots split tokens by context |
| "ID: 007, 7" | 7, 7 | 2 | Leading zeros normalized |
| "No numbers here" | - | 0 | Empty result set |
| "10 20 10 30 10 20" | 10×3, 20×2, 30×1 | 6 | Frequency ranking applied |
| "Price: $1,234.56" | 1, 234.56 | 2 | Commas break tokens |
| "Coordinates: 51.5074, -0.1278" | 51.5074, −0.1278 | 2 | Full decimal precision |
| "abc123def456ghi" | 123, 456 | 2 | Embedded numbers extracted |
| "0 0 0 1 1 2" | 0×3, 1×2, 2×1 | 6 | Zeros are valid numbers |
| "-1 -1 -2 +3" | −1×2, −2×1, 3×1 | 4 | Sign-aware extraction |
| "3.0 vs 3.00 vs 3" | 3×3 | 3 | Trailing zeros normalized |