Convert CSV Columns to Rows

Convert specific columns in your CSV data into rows. Restructure wide-format data into long-format by unpivoting selected columns into row entries. The inverse of the rows-to-columns operation.

Input CSV
Options
CSV CommentsLines starting with this symbol are comments and are automatically deleted.
Handle Incomplete CSVSelect a method to process an incomplete CSV file.If you selected the option "Fill with Custom Values", enter a custom value here.
Output CSV

What It Does

Convert specific columns in your CSV data into rows. Restructure wide-format data into long-format by unpivoting selected columns into row entries. The inverse of the rows-to-columns operation.

How It Works

Convert CSV Columns to Rows changes data from Columns into Rows. That is more than a cosmetic rewrite. Field layout, quoting, nesting, and even type representation can shift because the destination format has different rules and limits.

Conversion tools are constrained by the destination format. If the source can express nesting, comments, repeated keys, or mixed data types more richly than the target, the output may need to flatten or reinterpret part of the structure.

All processing happens in your browser, so your input stays on your device during the transformation.

Common Use Cases

  • Convert monthly columns (Jan, Feb, Mar) into a single Month column with row entries
  • Unpivot a wide survey response table into a long-format analysis table
  • Reshape wide-format data for import into databases that expect normalized rows
  • Convert crosstab reports into flat list format
  • Prepare data for visualization tools that require long-format input

How to Use

  1. Paste your CSV data into the input.
  2. Specify which columns to convert to rows.
  3. Set the name for the new key and value columns.
  4. Click Convert and copy the long-format output.

Features

  • Select multiple columns for conversion to rows
  • Generates key-value pair rows from column headers and values
  • Preserves non-selected columns as repeated identifiers
  • Handles empty cells in converted columns
  • Produces clean long-format output

Examples

Below is a representative input and output so you can see the transformation clearly.

Input
A,1,3
B,2,4
Output
A,B
1,2
3,4

Edge Cases

  • Very large inputs can still stress the browser, especially when the tool is working across many columns. Split huge jobs into smaller batches if the page becomes sluggish.
  • Source values that look similar can map differently in the target format when data types are inferred, flattened, or serialized.
  • If the output looks wrong, compare the exact input and option values first, because Convert CSV Columns to Rows should be repeatable with the same settings.

Troubleshooting

  • Unexpected output often means the input is being split or interpreted at the wrong unit. For Convert CSV Columns to Rows, that unit is usually columns.
  • If a previous run looked different, check for hidden whitespace, changed separators, or a setting that was toggled accidentally.
  • If nothing changes, confirm that the input actually contains the pattern or structure this tool operates on.
  • If the page feels slow, reduce the input size and test a smaller sample first.

Tips

Name your key column descriptively — instead of 'variable,' use 'month' or 'metric' or whatever the converted columns represent. This makes the output self-documenting.

Understanding Column-to-Row Conversion

This operation is commonly called "unpivoting" or "melting." It takes a wide table where information is spread across multiple columns and restructures it into a tall table where that same information is stacked in rows. The classic example: a table with 12 month columns becomes a table with a "month" column and a "value" column, with 12 rows per original row.

Why Long Format Matters

Many analysis tools and databases work better with long-format (normalized) data. SQL queries are simpler when each observation is a row rather than spread across columns. Visualization libraries like ggplot2, seaborn, and Vega-Lite expect long-format data for faceting and grouping. Pandas groupby operations work on rows, not columns.

The Conversion Process

When you unpivot columns C, D, and E while keeping columns A and B as identifiers, each original row produces three output rows. Row 1 with values in C, D, E becomes three rows: (A1, B1, "C", C1), (A1, B1, "D", D1), (A1, B1, "E", E1). The identifier columns (A, B) are repeated in each generated row to maintain the association.

Practical Example

A sales report has columns: Product, Q1_Sales, Q2_Sales, Q3_Sales, Q4_Sales. After unpivoting the quarter columns, you get: Product, Quarter, Sales. Each product now has 4 rows instead of 1, and you can group, filter, and chart by quarter using standard operations.

Frequently Asked Questions

How many rows will the output have?

Output rows = original data rows × number of columns being unpivoted. If you have 100 rows and unpivot 4 columns, the output has 400 rows.

What happens to empty cells in the unpivoted columns?

Empty cells produce rows with empty value fields. You can filter these out afterward if they represent missing data.

Can I unpivot all columns?

You need at least one column to serve as an identifier (kept as-is). If you unpivot all columns, there is no identifier to associate the values with their original row.

How do I reverse this operation?

Use the CSV Rows to Columns tool to pivot the data back to wide format.

Does the column header become a data value?

Yes. The column name becomes the value in the new 'key' column. For example, unpivoting columns 'Jan', 'Feb', 'Mar' produces rows where the key column contains 'Jan', 'Feb', or 'Mar'.

Can I unpivot by a pattern instead of listing every column?

This tool requires explicit column selection. If you have many columns following a pattern, list them individually.