A supplier sends an invoice as an email rather than a spreadsheet. A report quotes figures in running text. A log file mixes timings with messages. You need the numbers, perhaps to total them, check an average or paste them into a sheet, but they are wrapped in words, currency symbols and punctuation.
This guide explains what makes number extraction harder than it looks, especially separators and minus signs, and shows how to pull numbers out of any text and calculate totals in a browser, with spreadsheet formulas or on the command line.
Why extracting numbers is not trivial
Looking for runs of digits is a start, but real text has complications:
- Decimals.
12.5should be one number, not12and5. - Thousand separators.
1,249.99is one number, and so is8,100,000. - Regional formats. In much of Europe and South America,
1.234,56means one thousand two hundred and thirty-four point five six. Some countries use a space for thousands:1 234,56. - Negatives.
-150.00and−4.5(with a true minus sign, U+2212) are negative, but the hyphen in a range like10-20is not a minus sign. - Scientific notation.
1e-3and6.02E23appear in technical text. - Numbers inside identifiers. Invoice
#4471or a date12/05/2025contain digits you may or may not want.
Because the same characters mean different things in different formats, a reliable tool asks you which format your text uses, rather than guessing.
Decimal comma or decimal point?
| Written | Comma thousands | Dot thousands | Space thousands |
|---|---|---|---|
| One thousand two hundred and thirty-four point five six | 1,234.56 | 1.234,56 | 1 234,56 |
| Typical in | UK, US, India, many others | Much of continental Europe, South America | France, Scandinavia, standards documents |
Choose the wrong one, and 1.234 becomes 1.234 instead of 1,234, silently a thousand times smaller. When in doubt, look for a number with both separators, or check the country of origin.
Extract numbers in your browser
Our Number Extractor finds the numbers, converts them to plain values and calculates statistics.
- Open Number Extractor and paste into Text containing numbers. The Sample is an invoice-like note with currency, a discount, a percentage, a range and a date.
- Set Number format in your text: 1,234.56 (comma thousands), 1.234,56 (dot thousands), 1 234,56 (space thousands) or 1234.56 (no separators).
- Choose an Output format, such as One per line to paste into a spreadsheet column.
- Adjust the switches:
- Detect negatives reads
-5and−5as negative, while ranges like10-20stay positive. - Whole numbers only drops decimals.
- Scientific notation reads
1e-3and6.02E23as single numbers. - Remove duplicates keeps each value once.
- Keep as written outputs numbers with their original separators; off gives plain
1234.56form. - Append sum & average adds Count, Sum, Average, Min and Max under the list.
- Detect negatives reads
- Read the summary line, which shows the count, sum, average, min and max even if you have not appended them. Then Copy or Download.
Numbers directly attached to letters, such as the 2 in H2O, are skipped, while numbers after symbols like $ or # are found.
Other ways to extract numbers
Spreadsheets
If each cell has a single number mixed with text, Google Sheets can extract it:
=VALUE(REGEXEXTRACT(A2, "-?\d+(\.\d+)?"))
This pattern does not handle thousand separators, so remove them first with SUBSTITUTE(A2, ",", ""). Excel 365 has added text and regex functions in recent versions, and older versions rely on combinations of MID, FIND and array formulas, or on Flash Fill, which learns from an example you type. Once the numbers are in a column, SUM, AVERAGE, MIN and MAX do the rest, and the Average Calculator is a quick alternative for a pasted list.
Spreadsheets are better if the text is already tabular or you need the numbers to stay linked to other columns.
Paste as text into a spreadsheet
For simple tables pasted from emails, Text to Columns (Excel) or Split text to columns (Sheets) may be enough to separate numbers from labels, especially if they are divided by tabs or consistent spaces.
Command line
grep -Eo -- '-?[0-9]+(\.[0-9]+)?' report.txt | paste -sd+ | bc
This extracts plain numbers and adds them. It does not understand thousand separators or regional formats, so clean those first.
Tips and pitfalls
Exclude numbers you do not want
Dates, invoice numbers, page references and percentages will all be picked up. Either remove them from the input before extracting, or review the list and delete them. Extracting line by line from only the relevant part of the text is often simplest.
Percentages are just numbers
8.25% is extracted as 8.25. If you add it to currency amounts, the total is meaningless. Keep different kinds of values separate. The Percentage Calculator handles percentage maths properly.
Rounding in totals
Computers store decimals in binary, which can produce results such as 0.30000000000000004. The tool rounds its displayed statistics to avoid this noise, but if you need exact currency totals, check the final figure in a spreadsheet with appropriate rounding.
Spread, not just average
An average hides variation. If you need to know how spread out the values are, paste the extracted list into the Standard Deviation Calculator.
Frequently asked questions
How do I extract all numbers from a text?
Paste the text into a number extractor, choose the number format your text uses, and copy the list. It finds integers, decimals and, optionally, negatives and scientific notation.
How do I add up numbers written in a paragraph?
Extract them first, then sum them. Our tool shows the sum in its summary line, and Append sum & average adds it to the output.
How do I handle numbers like 1.234,56?
Choose 1.234,56 (dot thousands) as the number format. The tool then reads the dot as a thousands separator and the comma as the decimal point.
Will a range like 10-20 be read as a negative number?
No. With Detect negatives on, a minus sign counts only when it is not attached to a preceding number, so 10-20 gives 10 and 20.
Can I keep the original formatting of the numbers?
Yes. Turn on Keep as written to output each number with its original separators instead of the plain 1234.56 form.