CSV to Array Converter

Turn CSV or TSV into ready-to-paste arrays for JavaScript, Python, Java, C#, PHP, Go, Ruby and Rust, as a 2D array or header-keyed objects. The code updates as you type, and everything stays in your browser.

Paste CSV or TSV, or drop a .csv, .tsv or .txt file here.

Valid CSV · 4 rows · 4 columns · 151 B

Array code JavaScript

const data = [ {name: "John Doe", age: 25, city: "New York", active: true}, {name: "Jane Smith", age: 30, city: "London, UK", active: false}, {name: "Bob Johnson", age: 35, city: "Tokyo", active: true}, {name: "Alice Brown", age: 28, city: "San Francisco", active: true} ];

How to Use

  1. Open Settings and pick the programming language (JavaScript, Python, Java, C#, PHP, Go, Ruby or Rust). It is shown in the output header
  2. Paste your CSV in the left panel, or open a .csv, .tsv or .txt file with Open file. The array code appears as you type
  3. Adjust the delimiter, output format (2D array or object array), header handling and type detection in Settings. The summary shows the current values
  4. Copy the generated array code to your clipboard or download it as a file for use in your project

Pro Tips

  • Use the first row as headers for better object array output
  • Auto-detect data types converts strings to appropriate data types
  • The line under the editors shows how many rows and columns were read, and what to fix when something is off
  • All processing happens in your browser - no data is sent to servers

Turning CSV Rows into Language-Native Array Literals

What this converter does

A CSV file is just rows of values separated by a delimiter, but code needs those same rows as a real array literal. This tool parses CSV or TSV text and rewrites it as source you can paste straight into a project — a two-dimensional array of rows and columns, or an array of objects keyed by the header row. It reads the delimiter, splits each line into fields, and emits the result using the array and string syntax of the language you pick: JavaScript, Python, Java, C#, PHP, Go, Ruby, or Rust.

The code updates as you type, and a check line under the editors tells you how many rows and columns were read — or what to fix when the text can't be read.

When to use it

Reach for it whenever you have tabular data in a CSV export and need it as a literal inside a script — seeding a test fixture, hard-coding a lookup table, or dropping a small dataset into a demo without wiring up a file reader. Because each target language gets its native syntax, the output compiles or runs without hand-editing brackets and quotes.

The object-array mode is the fastest way to turn a spreadsheet into structured records: enable the header option and every row becomes an object whose keys come from the first line, ready to iterate over. If the destination is a data file rather than source code, the CSV ↔ JSON converter produces that shape instead, and when a fixture needs filler prose in one of its text columns, the Lorem Ipsum generator supplies it.

Example: three rows to an array literal

Take the CSV name,age,active on the first line, followed by Alice,30,true and Bob,25,false. As a 2D array in JavaScript it becomes [["name","age","active"],["Alice",30,true],["Bob",25,false]]. Switch to object-array output and you get [{"name":"Alice","age":30,"active":true},{"name":"Bob","age":25,"active":false}] instead. Pick Python and the same data comes back with True, False, and None in place of the JavaScript literals.

Delimiters, quoting, and types

The delimiter is configurable — comma, semicolon, tab, or pipe, plus a custom character for anything unusual — which matters for European exports that use semicolons or for TSV files. Auto type detection decides whether a field like 30 or true stays a bare number or boolean instead of a quoted string, and it can be turned off when you want every value kept as text. Files you open (CSV, TSV, or TXT) are parsed the same way as pasted text.

Frequently Asked Questions

Yes. Generate as many array literals as you like for JavaScript, Python, Java, C#, PHP, Go, Ruby, or Rust, in either 2D or object-array form. There are no paid tiers or usage caps.