π’ Extract Numbers from Text
By Shihab Mia Β· Updated 2026-07-13
Paste some text and press Extract numbers.
To extract numbers from text, paste your text into the box above and press Extract. The tool scans every character with a number pattern and returns a clean list of just the numeric values, the integers like 42 and the decimals like 3.14, in the order they appear. Along with the list you instantly get the count, the sum, the average, and the smallest and largest values, so you can total a pasted invoice or grab readings from a report without retyping anything. Choose a newline or comma separator, keep or strip negatives, sort ascending, then copy in one click. Everything runs in your browser, so nothing you paste is ever uploaded.
What is the Extract Numbers?
Extracting numbers from text means scanning a string and keeping only the numeric tokens, the integers (like 42), the decimals (like 3.14), and, if you want them, the negatives (like -7). Everything else, the words, punctuation, currency symbols and units, is discarded. The result is a tidy column or comma-separated list you can drop straight into a spreadsheet, a calculator, or your code, and because the same pass also totals the values you often do not need a second tool at all.
Under the hood the tool uses a regular expression to find the numbers. A regular expression (regex) is a compact pattern that describes the shape of the text you are searching for. The pattern here looks for an optional minus sign, one or more digits, and an optional decimal point followed by more digits, roughly written as -?\d+(\.\d+)?. That single pattern captures whole numbers and decimals in one pass, in the order they appear, which is why a phrase like 'Order 12 items at 4.50 each' yields 12 and 4.50. Developers reach for the same idea in code: JavaScript uses text.match(/-?\d+(\.\d+)?/g), Python uses re.findall, and Excel 365 exposes a REGEXEXTRACT function that does the equivalent.
Because the matching is purely about the characters, it does not understand meaning. A date like 2026-07-13 is read as the three numbers 2026, 7 and 13, and a phone number, IP address or version string is broken into its digit groups too. That is usually what you want when scraping figures out of prose, but it is worth knowing so the count and sum match your expectation. Thousands separators behave the same way: 1,250 is read as 1 and 250 because the comma breaks the digit run, so strip commas first when you need a grouped figure kept whole.
The statistics are worked out the moment the list is built. Count is how many tokens matched, sum adds them together, average is the sum divided by the count, and min and max are the smallest and largest matched values. If you untick Keep negatives, every leading minus sign is removed before these totals are calculated, so -50 is treated as the magnitude 50. This turns a wall of text into the same summary you would get from pasting the numbers into a spreadsheet and writing SUM and AVERAGE formulas, but in a single step.
The tool is deliberately format agnostic. It does not care whether your numbers arrive from a copied bank statement, a log file, a recipe, a scientific table, or a chat transcript, because it works on the raw characters rather than any particular file type. Scientific notation such as 1.5e3 is read as the digit groups 1.5 and 3 rather than as 1500, and number words such as 'twelve' are never matched because they contain no digits. Knowing these boundaries up front means the output always matches what you expect, with no silent surprises in the count.
Every calculation happens locally in JavaScript on your own device. Nothing you paste is sent to a server, logged, or stored, which is what makes the tool safe for private invoices, payroll figures, medical readings, or confidential logs. Close the tab and the data is gone. This client-side design is also why the extraction is instant even on long documents: there is no upload, no queue, and no round trip to wait on.
When to use it
- Pulling all the prices or amounts out of a pasted invoice, receipt, or bank statement to add them up quickly.
- Extracting measurements, quantities, or dosages from a recipe, spec sheet, or product description.
- Scraping numeric values out of a log file or report so you can paste them into a spreadsheet column.
- Grabbing scores, ages, or sensor readings from a paragraph of notes without retyping each one.
- Isolating order IDs, tracking numbers, or reference codes from an email or chat message.
- Getting a fast sum and average of figures buried in prose without opening Excel or a calculator.
How to use the Extract Numbers
- Paste or type the text that contains your numbers into the input box.
- Choose how to separate the output: one number per line, or comma separated.
- Optionally keep or strip negative signs, and tick Sort ascending to order the list.
- Press Extract numbers to see the list plus the count, sum, average, min, and max.
- Press Copy results to put the extracted list on your clipboard, ready to paste anywhere.
Formula & method
Worked examples
You paste the sentence: Buy 3 apples and 2 oranges for 4.50 dollars.
- The pattern scans left to right and matches each numeric token in order.
- It finds 3, then 2, then 4.50.
- count = 3 numbers
- sum = 3 + 2 + 4.50 = 9.5
- average = 9.5 / 3 = 3.166...
- min = 2, max = 4.50
Result: List: 3, 2, 4.50 - Count 3, Sum 9.5, Average 3.1666666667, Min 2, Max 4.5
You paste a short ledger: Income 1200, refund -50, fee -12.99, bonus 300.
- With Keep negatives ticked, the minus signs are kept.
- Matched tokens: 1200, -50, -12.99, 300
- count = 4 numbers
- sum = 1200 + (-50) + (-12.99) + 300 = 1437.01
- average = 1437.01 / 4 = 359.2525
- min = -50, max = 1200
Result: List: 1200, -50, -12.99, 300 - Count 4, Sum 1437.01, Average 359.2525, Min -50, Max 1200
You paste a date and code: Invoice 2026-07-13, ref A17, total 89.95.
- The tool reads characters, not meaning, so the date splits into its digit groups.
- Matched tokens in order: 2026, 07, 13, 17, 89.95
- The letter A in A17 is skipped, leaving 17.
- count = 5 numbers
- sum = 2026 + 7 + 13 + 17 + 89.95 = 2152.95
Result: List: 2026, 07, 13, 17, 89.95 - Count 5, Sum 2152.95. Note how the date inflated the count.
What counts as a number, and what gets ignored
| Input fragment | Extracted as | Why |
|---|---|---|
| 42 | 42 | A plain integer is matched whole. |
| 3.14 | 3.14 | A decimal point with digits on both sides is kept. |
| -7 | -7 (or 7) | A leading minus is kept unless you strip negatives. |
| $1,250 | 1 then 250 | The comma is a separator, so it splits the number. |
| 2026-07-13 | 2026, 7, 13 | Each digit group is read as its own number. |
| 1.5e3 | 1.5, 3 | Scientific notation is read as separate digit groups, not 1500. |
| A17 | 17 | Letters are ignored; the digit run inside is kept. |
| fifty | (nothing) | Number words are not digits, so they are ignored. |
Common ways to extract numbers, tool versus code
| Method | How you do it | Best for |
|---|---|---|
| This tool | Paste text, press Extract | A quick one-off with instant totals, no setup. |
| JavaScript | text.match(/-?\d+(\.\d+)?/g) | Pulling numbers inside a web script or Node app. |
| Python | re.findall(r'-?\d+\.?\d*', text) | Batch processing many files or automating a job. |
| Excel 365 | =TEXTJOIN together with REGEXEXTRACT | Cleaning a column of mixed text in a spreadsheet. |
| Google Sheets | =REGEXEXTRACT(A1, "-?\d+\.?\d*") | One cell at a time inside an existing sheet. |
Common mistakes to avoid
- Expecting thousands separators to stay together. A figure written as 1,250 is read as two numbers, 1 and 250, because the comma breaks the digit run. Remove the commas first (or paste 1250) if you need it counted as one value.
- Forgetting that dates and codes are split. Strings like 2026-07-13, version 1.2.3, an IP address, or a phone number are broken into their separate digit groups. The tool reads characters, not meaning, so these inflate your count.
- Leaving negatives in when you wanted magnitudes. If your sum looks lower than expected, a minus sign was probably kept. Untick Keep negatives to treat -50 as 50 before the count and sum are worked out.
- Missing number words. Words such as "twelve" or "half" are not numeric digits, so they are not extracted. This tool only finds figures written with digits.
- Assuming scientific notation is evaluated. A value like 1.5e3 is not converted to 1500. The tool matches the digit groups 1.5 and 3 separately, so expand scientific notation to plain digits first if you need the real value.
- Overlooking that percentages and currency symbols are dropped. In 20% off or $89.95 the symbols are discarded and only the numbers 20 and 89.95 are kept. The figure stays correct, but the unit meaning is lost, so label your output yourself.
Glossary
- Integer
- A whole number with no decimal part, such as 5, 0, or 42.
- Decimal
- A number with a fractional part written after a decimal point, such as 3.14 or 0.5.
- Regular expression
- A compact text pattern (regex) used to search for tokens that match a given shape, here, numbers.
- Token
- A single matched chunk of text. Each number the tool pulls out is one token.
- Sum
- The total you get by adding every extracted number together.
- Average
- The mean value, worked out as the sum divided by the count of numbers.
- Scientific notation
- A shorthand for very large or small numbers using e, such as 1.5e3 meaning 1500.
- Thousands separator
- A comma or space used to group digits, as in 1,250, which this tool treats as a break between numbers.
Frequently asked questions
How do I extract numbers from text?
Paste your text into the input box and press Extract numbers. The tool scans the text with a regular expression, pulls out every integer and decimal, and shows them as a list along with the count, sum, average, min, and max. You can then copy the list with one click.
Does it handle decimals and negative numbers?
Yes. Decimals such as 3.14 are matched whole, and negative numbers such as -7 are kept by default. If you only want positive magnitudes, untick Keep negatives and any leading minus sign is removed before the numbers are listed and summed.
Why is 1,250 split into 1 and 250?
The comma is treated as a separator between numbers, so a thousands separator breaks the digit run in two. To count 1,250 as a single value, remove the comma first or paste it as 1250.
Can it add up the numbers it finds?
Yes. As soon as you extract, the tool shows the total count, the sum of every number found, the average (sum divided by count), and the smallest and largest values, so you do not need a separate calculator.
Is my text sent anywhere?
No. The extraction runs entirely in your browser using JavaScript. Nothing you paste is uploaded or stored, which makes the tool safe to use with private invoices, payroll figures, logs, or notes.
Can I get the numbers comma separated instead of one per line?
Yes. Choose the Comma option under Separate by and the output is joined with commas. Pick Newline to get one number per line, which is handy for pasting into a spreadsheet column.
How do I extract numbers from a string in JavaScript?
Use the match method with a global regular expression: text.match(/-?\d+(\.\d+)?/g). It returns an array of the numbers as strings, so wrap them with Number or map(Number) to add them up. This tool uses the same pattern, so the results line up with your code.
How do I extract numbers from text in Excel or Google Sheets?
In Excel 365 and Google Sheets you can use REGEXEXTRACT with a pattern like "-?\d+\.?\d*" to pull a number from a cell, or TEXTJOIN to combine several. For a fast one-off across a whole block of text, pasting it here is quicker than building the formula.
Does it extract phone numbers or dates as single values?
No. A phone number, date, or version string is split into its separate digit groups because the tool reads characters, not meaning. For example 2026-07-13 becomes 2026, 7, and 13. Remove the dashes first if you want a single joined value.
Can it remove duplicates or sort the numbers?
You can tick Sort ascending to order the extracted list from smallest to largest, which also makes any repeated values sit next to each other so they are easy to spot. The default keeps every match in its original order of appearance.