How to convert csv to json for mongodb import
- Step 1Export your data as CSV — From your existing system, export the records you want to seed into MongoDB as a UTF-8 CSV.
- Step 2Drop the CSV in the converter — The first row becomes the JSON keys, which match your Mongoose schema field names.
- Step 3Choose array or NDJSON output — Pick array-of-objects for insertMany, or NDJSON for mongoimport without the --jsonArray flag.
- Step 4Run mongoimport or Mongoose seed — Pipe the file into mongoimport --uri ... --collection X --file out.json --jsonArray, or import it from your seed script.
Frequently asked questions
Why convert CSV to JSON when mongoimport accepts CSV?+
Direct CSV import stores every value as a string. JSON preserves numeric, boolean, and nested types — useful for Mongoose schemas with strict casting.
What if my data has embedded objects or arrays?+
CSV cannot represent nested structures cleanly. Use the grouped output mode or pre-process with the Find & Replace tool, then convert.
Is this tool safe for production data?+
Yes. Conversion is local in your browser — no file is uploaded. Even so, never run an untested import against production directly; seed against a staging cluster first.
Privacy first
Conversion runs locally in your browser. No file is uploaded — only metadata counters are saved for signed-in dashboard stats.