Add Row Numbers to CSV
Add Row Numbers inserts a sequential ID column into a CSV. You set the column name, the first number and whether the column sits at the start or the end of each row. The numbers follow the data rows in file order, with no gaps and no repeats.
Use it before an import that requires a key column, or to give reviewers a line number they can quote in a ticket.
Key features
- Custom column name
- Any whole number as the start value
- First or last column
- Rejects a name that already exists
About the CSV to CSV format
The first data row receives the start value and each following row adds one. The header row carries the column name. That name must not match an existing header when letter case is ignored, so Email and email count as the same name. The start value must be a whole number, and zero or negative values are allowed. Numbers are written as plain digits with no padding, so a start of 1 produces 1, 2, 3 and never 001.
How it works
Rows are read in order. For each data row the ID is the start value plus the row's position, converted to text. The ID column is inserted at the chosen end of the header list, and every other cell is copied through unchanged.
Common use cases
- Adding a primary key to a spreadsheet before loading it into a table that needs one
- Giving reviewers a stable line_no to cite in a data quality ticket
- Numbering the parts of a split file so they can be reassembled in order
How to use this tool
- Paste the rows into the text box, or select a file with Click to upload.
- Set the ID column name, the start number and the position.
- Click Add numbers, then copy or download the result.
Example
Two-row contact list (input)
name,city
Ada,London
Grace,ArlingtonStart 101, last column named line_no (output)
name,city,line_no
Ada,London,101
Grace,Arlington,102Tips for best results
- Put the ID first when a loader reads columns by position. Put it last when people read the file and expect the labels to stay at the left.
- Start at 2 if you want the numbers to match spreadsheet row numbers, since the header occupies row 1.
Common errors and how to fix them
- A column named "x" already exists. Choose another name.
- The ID name matches a header in the file, ignoring case. Pick a different name such as row_id or line_no.
- Enter a name for the ID column.
- The name box is blank. Type the column name you want the numbers stored under.
- Start number must be a whole number.
- The start box holds a decimal, a letter or nothing. Enter an integer such as 1 or 101.
Best practices
- Name the column for its job, such as row_id for a database loader or line_no for review notes.
- Use the same start value every time you re-export the same file, so references from earlier reviews still line up.
Frequently asked questions
Can the numbering start at zero or go negative?
Yes. Any whole number works as the start value, and the sequence then counts up from it.
What happens if I delete a row after numbering?
The numbers are not recalculated, so the sequence has a gap. Remove rows first and add the numbers afterwards.
For more background on data formats and conversion workflows, read our format guides.