JSON to Mongoose schema
Turn a JSON sample into a ready-to-use Mongoose schema and model.
JSON to Mongoose schema
Paste a sample JSON document — a single object or an array of them — and this tool infers the shape and generates a working new mongoose.Schema() definition with a model export. It is built for the moment you have a JSON payload from an API, a seed file or an old database dump and need a Mongoose model, without typing every field by hand.
The tool reads real values to choose real types: strings become String, numbers become Number, an ISO-looking date string becomes Date, and a field whose name ends in "Id" (or the array form "…Ids") becomes an ObjectId reference, since that is how a hand-written schema would model it. Nested objects become their own new mongoose.Schema({...}) inside the parent, and an array of objects becomes an array of that nested schema. Options handle the rest: name the model, mark scalar fields as required, carry the sample's own values over as defaults, toggle the timestamps option, decide whether subdocuments keep their own _id, and switch "Id"-suffixed fields between ObjectId and plain String. Pick CommonJS or ES module syntax, and optionally add a matching TypeScript interface below the model.
Feeding an array of sample documents instead of one lets the tool notice fields present in only some of them, useful when real data is not perfectly uniform — those become optional in the generated interface. Windows and Unix line endings are treated identically, and input too large to process comfortably is reported instead of freezing the tab. The tally under the output shows the field count, the nested-schema count and the character count.
Everything runs locally in your browser — the JSON you paste, which may contain real records, is never uploaded anywhere. When the schema looks right, copy it, download it as a .txt file to paste into your own .js or .ts file, or send the output back into the input to refine it further.