Menu

Extract Numbers From Text

Paste any text and get every number in it as a clean list, one per line, comma-separated or tab-separated for a spreadsheet, with decimals, minus signs and thousands separators kept as written.

0 words 0 characters 0 lines

Continue with this text: Remove numbersSort linesComma list

Your text stays in your browser: nothing is uploaded or stored on a server.

How to use it

  1. Paste your text into the box, click Open file to load a .txt or .csv file, or click Example to try the sample invoice.
  2. Read the result. The numbers appear in the order they occur in the text, and the line under the result shows the count, for example “7 numbers”.
  3. Set the options if needed: Whole numbers only, Remove duplicates, Sort smallest to largest and One per (Line, Comma or Tab).
  4. Click Copy or Download .txt, or send the list straight to Sort lines or Comma list with the links under the result.

What counts as a number

The tool looks for runs of digits 0-9 and keeps the characters that belong to the number around them:

  • A minus sign. A hyphen directly before the digits is kept when no letter or digit comes right before it: -3.5 stays -3.5 and (-5) gives -5, but 10-20 gives 10 and 20. The Unicode minus sign is kept and written as a hyphen (−5 gives -5). A plus sign is dropped, so +5 gives 5, and so is an en dash, which usually marks a range (–5 gives 5).
  • A decimal part. A dot followed by digits is kept: 4.99, 0.5, 1,234.56, and also .5 with no leading zero.
  • Thousands separators. Commas are kept when they split the number into groups of exactly three digits: 1,234,567 and 10,000,000.5 come out whole. Otherwise the comma ends the number, so 1,2345 gives 1 and 2345.
  • An exponent. An e or E followed by digits is kept: 1e6 and 2.5e-3 come out whole.
  • Everything else is left out: currency symbols, percent signs, units, letters and spaces. $12.50 gives 12.50, 50% gives 50.

The numbers are copied exactly as they appear, so leading zeros stay (007 gives 007) and 12.50 is not shortened to 12.5. That makes the tool safe for order numbers and codes as well as amounts.

Running the Example text with One per: Comma gives:

Invoice 2041: 3 items at $12.50, shipping 4.99, total $42.49.
Temperature dropped to -3.5 degrees; population 1,234,567.
2041, 3, 12.50, 4.99, 42.49, -3.5, 1,234,567

The options

Option What it does Example text Result
None (default) Every number, in order, as written Scores: 88, 92, 75, 92, 100 88, 92, 75, 92, 100
Remove duplicates Keeps the first copy of each value (3 and 3.0 match) Order #1001 … #1002 … #1001 1001, 1002
Sort smallest to largest Orders by value, negatives first 10 9 100 -2 1,000 2.5 -2, 2.5, 9, 10, 100, 1,000
Duplicates + sort A sorted list of distinct values Scores: 88, 92, 75, 92, 100 75, 88, 92, 100
Whole numbers only Keeps only numbers without a decimal point $12.50 and 1,234,567 1,234,567

Sorting compares values, not text. 1,000 sorts after 100 because the commas are ignored for the comparison, and -2 comes before 2.5. Numbers with the same value keep their original order. One side effect: version numbers sort as decimals, so 2.10 comes before 2.9.

One per sets the separator. Line gives a column, Comma gives a single line such as 2.5, -1.25, 1.25, and Tab (spreadsheet) puts the numbers in one row of cells when pasted into a spreadsheet. If your numbers contain thousands separators, choose Line or Tab: in a comma list, 1,250,000.75, 980,500 is hard to read and a CSV import would split it at every comma.

Whole numbers only

Whole numbers only finds each full number first and then keeps the ones written without a decimal point. Decimals are left out, not rounded or split:

Before After (Whole numbers only)
$12.50 and -3.5 and 1,234,567 1,234,567
2.0 and 3 3
1e6 and 2.5e-3 1e6

The rule looks at how the number is written: 2.0 is dropped because it has a decimal point, and 1.5e3 is dropped too even though its value is 1,500. The sample invoice gives 3 numbers with this option (2041, 3, 1,234,567) instead of 7. If you want amounts rounded rather than dropped, extract them normally and round them in a spreadsheet.

Edge cases to check

These are the results the tool gives today, so you know what to look for in the output:

Text Result Why
10-20 10, 20 A hyphen after a digit is not a minus sign.
2026-10-21 2026, 10, 21 Dates written with hyphens give their parts.
555-123-4567 555, 123, 4567 Use the phone number extractor for whole phone numbers.
x-1 1 A letter before the hyphen also rules out a minus sign.
v1.2.3 1.2, 3 Version numbers are read as a decimal and a whole number.
1.299,00 € 1.299, 00 European decimal commas are not recognized.
1 000 000 1, 000, 000 Spaces as thousands separators split the number.
3:45 3, 45 Times give hours and minutes separately.
½, 12 nothing Only the ASCII digits 0-9 are found.

For European formats, swap . and , first using Find and replace. Text with no digits gives an empty result and “0 numbers”.

When people need it

  • Totals from an invoice, receipt or bank statement copied from a PDF: extract the amounts with One per: Line and paste them into a spreadsheet column to add them up.
  • IDs from a log or an export: pull order numbers or ticket numbers out of a block of notes, tick Remove duplicates, and use the comma separator to turn the list into an SQL IN (…) list.
  • Survey or test scores typed into a document: sort smallest to largest to see the range, the lowest and the highest at a glance.
  • Measurements from a lab report or product listing: decimals and negatives are kept, so -1.25 kg gives -1.25.
  • Cleaning in the other direction: to keep the words and drop the digits, use Remove numbers. The extraction guide covers emails, links and numbers together.

In Excel and Google Sheets

Both spreadsheets have a REGEXEXTRACT function. In Excel for Microsoft 365, =REGEXEXTRACT(A2,"-?\d+(\.\d+)?",1) returns all the numbers in cell A2 as an array (return mode 1); return mode 0, the default, gives the first match only. In Google Sheets, REGEXEXTRACT(text, regular_expression) returns the first match, so it gives one number per cell. These patterns do not handle thousands separators. For a whole column, or text that is not in a spreadsheet yet, pasting it here and pasting the list back is usually quicker.

Questions

How do I extract only the numbers from a text string?

Paste the text in the box. Every number appears in the result straight away, one per line, and the line under the result says how many were found. Copy the list or change One per to Comma or Tab (spreadsheet).

Are decimals and negative numbers kept?

Yes. "4.99" stays 4.99 and "-3.5" stays -3.5. A hyphen counts as a minus sign only when no letter or digit is directly before it, so ranges and dates such as 10-20 or 2026-10-21 give positive numbers (10 and 20; 2026, 10 and 21).

How do I extract numbers from text in Excel?

In Excel for Microsoft 365, =REGEXEXTRACT(A2,"-?\d+(\.\d+)?",1) returns every match in the cell as an array. Older versions of Excel do not have REGEXEXTRACT, so pasting the column here is quicker than building a formula from MID and FIND.

How do I extract numbers from text in Google Sheets?

=REGEXEXTRACT(A2,"-?\d+(?:\.\d+)?") returns the first number in the cell only. To get every number from a block of cells, copy them, paste them here and paste the result back with One per: Line.

Does "Remove duplicates" treat 3 and 3.0 as the same number?

Yes. Duplicates are compared by value, so 3, 3.0 and 03 count as one number, and so do 1,234 and 1234. The first spelling in the text is the one kept.

Can it read numbers written as words, like "twenty"?

No. Only digits 0-9 are found. To go the other way, the number to words converter writes a number out in words.

Is my text uploaded anywhere?

No. The extraction runs in your browser and the text is never sent to a server.