User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
Input CSV
Drop a .csv file here or click to upload
Output (Transposed)
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

About

Transposing a CSV matrix is the act of swapping its row index i with its column index j, producing a new matrix where element M[i][j] becomes MT[j][i]. This sounds trivial until your data contains commas inside quoted fields, escaped double-quotes, or ragged rows with inconsistent column counts. A naive split-by-comma approach will corrupt quoted fields containing delimiters, producing silently wrong output. This tool implements a full RFC 4180-compliant parser that handles every edge case before performing the transpose.

The tool accepts any delimiter (comma, semicolon, tab, pipe) and correctly processes fields wrapped in double quotes, including fields containing newline characters. Ragged rows (rows with fewer columns than others) are padded with empty values during transposition. Limitation: this operates entirely in-browser memory, so files exceeding approximately 50 MB may cause slowdowns depending on device RAM. For structured database exports, verify that your quoting rules match RFC 4180 before relying on the output.

csv converter transpose csv columns to rows csv tool data transformation csv transpose matrix transpose

Formulas

The transpose operation converts a matrix of m rows and n columns into a matrix of n rows and m columns:

MT[j][i] = M[i][j] for 0 โ‰ค i < m, 0 โ‰ค j < n

Where M is the original parsed CSV matrix, m = number of rows (records), n = maximum number of columns across all rows, i = row index, and j = column index. For ragged matrices where row lengths differ, the effective column count is: n = max(len(rowi)) for all i. Cells beyond a short row's length are treated as empty strings.

The CSV parser uses a finite state machine with three states: FIELD_START, UNQUOTED, and QUOTED. Transition rules: encountering a quote character at FIELD_START enters QUOTED mode. Inside QUOTED, a double-quote ("") is an escaped literal quote. A lone quote exits to UNQUOTED. Delimiter or newline in UNQUOTED commits the field. This guarantees correct parsing per RFC 4180.

Reference Data

DelimiterCommon NameCharacterTypical File ExtensionRFC/StandardCommon Use Case
CommaCSV,.csvRFC 4180Spreadsheet exports, database dumps
TabTSV\t.tsv, .txtIANA TSVBioinformatics, Unix tools
SemicolonSCSV;.csvEuropean locale CSVExcel (EU locale), SAP exports
PipePSV|.txt, .datHL7, EDIHealthcare data, financial feeds
Colon - :.txt/etc/passwdUnix system files
SpaceSSV.txt - Fixed-width legacy data
Tilde - ~.txt - Custom enterprise exports
Caret - ^.txt - Mainframe data interchange
Double QuoteQuote Escape"" - RFC 4180 ยง2.7Escaping quotes inside quoted fields
CRLFRow Separator\r\n - RFC 4180 ยง2.1Standard CSV row break
LFRow Separator\n - Unix conventionLinux/macOS CSV files
BOMByte Order MarkU+FEFF - UnicodeUTF-8 BOM prefix from Excel
NULLEmpty field"" - RFC 4180 ยง2.6Represents missing data
Newline in fieldEmbedded LF\n inside quotes - RFC 4180 ยง2.6Multi-line addresses, descriptions

Frequently Asked Questions

The parser uses a finite state machine compliant with RFC 4180. When it encounters a double-quote character at the start of a field, it enters QUOTED mode. In this mode, commas (or whatever delimiter is selected) are treated as literal characters within the field value, not as field separators. The field only terminates when a closing double-quote is followed by a delimiter, newline, or end-of-input. This means a field like "New York, NY" is correctly parsed as a single value containing the comma.
During transposition, the tool first determines the maximum column count n across all rows. Rows with fewer than n fields are padded with empty strings. This ensures the transposed matrix is rectangular. For example, if row 1 has 5 fields and row 2 has 3 fields, row 2 is padded with 2 empty fields before transposing. The output will contain n rows, each with m columns.
Yes. Many CSV files exported from Microsoft Excel contain a UTF-8 BOM prefix (U+FEFF) at the start of the file. The parser detects and strips this invisible character before processing. If left unhandled, the BOM would become part of the first field value, causing comparison mismatches and display anomalies. The tool removes it silently.
Yes. Select "Tab" from the delimiter dropdown before pasting or uploading your data. The parser treats the chosen delimiter as the field separator. This works identically for semicolons (common in European Excel exports), pipes (used in HL7 healthcare data), or any custom single-character delimiter. The quoting rules still apply regardless of delimiter choice.
The tool runs entirely in your browser. Practical limits depend on your device's available RAM. Files up to approximately 10-20 MB (roughly 200,000 rows ร— 50 columns) process in under 2 seconds on modern hardware. Files between 20-50 MB will work but may take several seconds. Beyond 50 MB, you risk browser memory pressure. The tool shows a progress indicator and processes in chunks to keep the UI responsive.
Per RFC 4180 section 2.7, a double-quote inside a quoted field is escaped by doubling it. The input ""Hello"" World" represents the value "Hello" World. The parser correctly unescapes these during parsing and re-escapes them during output serialization. The round-trip preserves all original quote characters faithfully.
No. The tool operates on JavaScript strings (UTF-16 internally). All Unicode characters - including CJK, emoji, RTL text, and diacritics - pass through unchanged. The downloaded output file is encoded as UTF-8 with no BOM. If you need a BOM for Excel compatibility, some versions of Excel auto-detect UTF-8 without it; for older versions, you may need to import via the Data tab.