Excel, CSV & JSON to JavaScript Array Converter

Paste spreadsheet rows or JSON and get a clean JavaScript array or object literal for your code, tests, mock data or config.

Runs in your browserUpdated
Open file (.xlsx, .csv, .json)
Input
Shape
Indent

Input preview

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the Excel, CSV & JSON to JS Array

  1. Paste CSV, Excel cells or JSON, or open a file.
  2. Choose the shape: an array of objects, rows as arrays, or an object keyed by the first column.
  3. Pick the declaration (const, export const, module.exports…), quote style and indentation.
  4. Copy the code or download it as a .js file.

What does a CSV to JavaScript array converter do?

It turns rows of a spreadsheet into a JavaScript literal you can drop into source code — handy for mock data, Storybook stories, unit tests, dropdown options, small lookup tables and static sites that do not need a database or a runtime CSV parser.

export const products = [
  { id: 1, name: 'Ada Lovelace', active: true },
  { id: 2, name: 'Grace Hopper', active: true },
];

JavaScript literal vs JSON

JSON is a strict subset of JavaScript syntax, but hand-written JavaScript is usually more relaxed. This tool writes idiomatic JavaScript:

  • Unquoted keys when the key is a valid identifier (name:), quoted only when needed ('first name':).
  • Single or double quotes to match your Prettier or ESLint settings.
  • Trailing commas, which keep diffs to one line when you add rows.
  • Real types: numbers, booleans and null are not quoted; values with leading zeros stay strings.

Shapes and declarations

OptionOutput
Objects[{ id: 1, … }, …] — the usual array of records
Rows (lists)[['id', 'name'], [1, 'Ada']] — header first, like a spreadsheet
Keyed by 1st column{ 'KB-001': { … } } — instant lookups by ID
export const / export defaultES modules (Vite, Next.js, modern Node)
module.exportsCommonJS (older Node.js code)

With JSON input, Keep original JSON structure converts nested objects and arrays as they are. Need TypeScript types for the data? Generate them with JSON to TypeScript. For PHP projects use CSV to PHP array.

Tools that pair well with the Excel, CSV & JSON to JS Array

  • Excel to JSON — Open an .xlsx workbook or paste cells straight from Excel or Google Sheets and get clean JSON.
  • JSON to Excel — Turn a JSON array into a real Excel workbook.
  • CSV & Excel to SQL — Paste CSV or Excel cells, or open an .xlsx file, and get ready-to-run CREATE TABLE and INSERT statements with correctly escaped values for your database.
  • JSON to SQL — Paste a JSON array and get SQL that creates the table and inserts every object as a row — nested objects become columns or JSON values, and every string is escaped for your dialect.

Frequently asked questions

How do I convert CSV to an array of objects in JavaScript?
Paste the CSV with a header row and keep the Objects shape. Each row becomes an object whose keys are the column names.
Can I use the output in TypeScript?
Yes — the literal is valid TypeScript. Add a type annotation, or generate an interface from the data with the JSON to TypeScript tool.
Why are some numbers in quotes?
Values such as ZIP codes or IDs with leading zeros, and integers too large for JavaScript numbers, are kept as strings so they are not changed.
Is the data uploaded?
No. Conversion runs entirely in your browser.

Related tools