Staaarter

CSV Column Inserter

Adds a brand-new column at a user-specified 0-based index in every row, with a header name and fill value you choose, shifting later columns to the right to make room. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-29
By Staaarter Team
columnstructuralinsert

Overview

Introduction

Sometimes a new column doesn't belong at the start or the end, it needs to sit between two existing ones to match a template or a downstream schema. This tool inserts a column at exactly the index you specify.

It generalizes the "start" and "end" cases into one tool with a single extra number field: the target index.

What Is CSV Column Inserter?

A structural CSV tool that inserts one new column at any 0-based index in every row, using your chosen header name for row 0 and a repeated fill value for every data row.

Columns at or after the target index shift one position to the right to make room; columns before it are untouched.

How CSV Column Inserter Works

The input is parsed into a grid and padded to a uniform width, then the target index is clamped into the valid range `[0, width]`.

Each row is split at that index and a new cell is spliced in between the two halves, then the grid is re-serialized back into CSV text.

When To Use CSV Column Inserter

Use it when a target schema or import template expects a new field at a specific position, not just first or last.

It's also useful for reconstructing a column that was accidentally deleted, back at its original index.

Features

Advantages

  • Supports any target position, not just the start or end.
  • Out-of-range indexes are clamped rather than rejected, so you can't easily corrupt the output with a typo'd index.
  • Preserves RFC 4180 quoting on both read and write.

Limitations

  • Every data row gets the same fill value; there's no per-row value support in this tool.
  • Only comma-delimited CSV is supported.

Examples

Inserting a column at index 1

Input

id,amount
1,120
2,90

Output

id,name,amount
1,unknown,120
2,unknown,90

Inserting at index 1 places "name" (filled with "unknown") between the existing "id" and "amount" columns.

Best Practices & Notes

Best Practices

  • Double-check the target index against the header row's current column count before running, since off-by-one is the most common mistake here.
  • Use Column Prepender or Column Appender instead when you specifically mean index 0 or the last index, they're simpler shortcuts for those cases.
  • Follow up with CSV Column Replacer if different rows need different values in the new column.

Developer Notes

Implemented with `row.slice(0, at)` and `row.slice(at)` around the new cell, where `at = Math.min(index, width)` clamps any out-of-range input rather than throwing.

CSV Column Inserter Use Cases

  • Matching a new column's position to a fixed import template that expects fields in a specific order
  • Restoring a previously deleted column back to its original index
  • Building up a CSV's structure incrementally, one inserted column at a time

Common Mistakes

  • Off-by-one errors when counting the target index, remember it's 0-based and counts from the left.
  • Expecting per-row values from a single fill-value field; use CSV Column Replacer afterward for that.

Tips

  • If you're not sure of the exact index, insert at the end first with a placeholder, then use Column Swapper to move it into place.
  • Leave the fill value blank to insert an empty placeholder column.

References

Frequently Asked Questions