By · Updated

Extract Numbers From Text

Get Numbers From a String With Sum, Mean and Thousands Separators

No ratings yet

OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.

How the Extract Numbers From Text works

Extract numbers from text of any kind: invoices, logs, chat messages, scraped pages or notes. Paste it in and every number comes out on its own line, with negatives, decimals and thousands separators handled, plus the count, sum, mean, smallest and largest.

How to extract numbers from text

The extractor scans for runs of digits. A comma followed by exactly three digits is read as a thousands separator in the default format, so 1,250 is one number, while "2,5,8" is three. Switch the format to Dot for European style, where 1.234,56 is one thousand two hundred and thirty-four point five six. A minus or the Unicode minus sign directly before a digit makes the number negative, unless it follows a letter or digit, so a phone number like 555-0134 gives two positive numbers rather than a subtraction.

The formula for the mean shown in the stats is sum ÷ count, over the numbers extracted, after any de-duplication.

First example. "Paid £19.99, £5 and £120.50 on 3 May" gives 19.99, 5, 120.5 and 3: count 4, sum 148.49, mean 37.1225.

Second example. With Unique on and Sort set to Descending, "3, 7, 3, 10, 7" gives 10, 7 and 3.

How many numbers will a date give? A date such as 2024-03-15 gives three numbers, 2024, 3 and 15, because the hyphens separate digits; leading zeros are dropped.

What the default settings extract from common snippets

Text Numbers extracted Count
Total: 42 42 1
Price $19.99 19.99 1
1,250 visitors 1250 1
Temperature -5 °C -5 1
Balance −120.50 -120.5 1
Call 555-0134 555, 134 2
Date 2024-03-15 2024, 3, 15 3
Version 3.2.1 3.2, 1 2
Size 1920x1080 1920, 1080 2
50% off 50 1
10kg and 2.5kg 10, 2.5 2
Order #A1023 1023 1
1e6 records 1, 6 2
€1.234,56 (European) 1.234, 56 2
3/4 cup 3, 4 2
Room 12B 12 1
0.5 and .75 0.5, 75 2
Q3 2025 3, 2025 2
2,5,8 comma list 2, 5, 8 3
12:30 pm 12, 30 2
x-3 (hyphen after a letter) 3 1
(-7) in brackets -7 1
+44 20 7946 0000 44, 20, 7946, 0 4
€ 1 000 000 with spaces 1, 0, 0 3

Tips and pitfalls

Check the format setting before trusting a sum: a European price list read with the Comma format turns 1.234,56 into 1.234 and 56. Scientific notation such as 1e6 is read as 1 and 6. Version numbers and IP addresses split into parts. For phone numbers, choose No for negatives so dashes are never read as minus signs.

FAQ

Does it handle decimals and thousands separators?

Yes. The default format reads 1,234.5 as one number. Choose "Dot (1.234,5)" for numbers written the continental European way, or None to treat every comma and dot as a separator between numbers.

Can I get only whole numbers?

Set "Include decimals" to No. A number such as 19.99 then comes out as 19 and 99, so it is best used on text where dots are full stops or separators rather than decimal points.

Can it add up the numbers it finds?

Yes. The stats below the result show the count, sum, mean, smallest and largest of the numbers extracted, so you can total the amounts in a pasted statement or list without a spreadsheet.

Why is a dash not read as a minus sign?

A minus counts only when it is directly before a digit and not straight after a letter, digit or dot. That keeps ranges such as 10-20, dates and phone numbers positive, while -5 or (−7) stay negative.

Is my text uploaded?

No. Extraction runs in your browser with JavaScript and nothing is sent to a server, so financial statements, logs and other private text stay on your own device.

See also: all Lists & Lines tools, Writing & Editing, Markdown & HTML, Ciphers & Alphabets.

Related tools