Comment utiliser : Excel, CSV & JSON to JS Array
- Paste CSV, Excel cells or JSON, or open a file.
- Choose the shape: an array of objects, rows as arrays, or an object keyed by the first column.
- Pick the declaration (
const,export const,module.exports…), quote style and indentation. - Copy the code or download it as a
.jsfile.
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
nullare not quoted; values with leading zeros stay strings.
Shapes and declarations
| Option | Output |
|---|---|
| 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 default | ES modules (Vite, Next.js, modern Node) |
module.exports | CommonJS (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.
Aussi recherché comme : csv to js array, excel to javascript array, csv to array of objects, json to javascript object, csv to js object, spreadsheet to javascript, csv to typescript array.
Outils complémentaires : 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.
- CSV to JSON — Paste CSV or TSV and get a JSON array of objects.
- Générateur de données factices — Créez jusqu'à 10 000 lignes de données de test réalistes — utilisateurs, produits, commandes, adresses, entreprises ou enregistrements API imbriqués — ou élaborez votre propre schéma.
- JSON to Excel — Turn a JSON array into a real Excel workbook.