Schema Inference Tool

Every new integration starts the same way: an API returns a JSON blob and you need a model to hold it. Typing out 20 fields by hand is tedious and error-prone. This tool parses a sample JSON object, picks a column type for each key, and emits a ready-to-paste schema in the flavor you want: SQL CREATE TABLE, Mongoose schema, or Sequelize model definition.

How to infer a schema from JSON

  1. 1

    Paste a sample object

    Drop in one JSON object, or an array of objects (the first object in the array is read). Use a complete record with every field filled so each column gets a type.

  2. 2

    Pick the output format

    SQL CREATE TABLE (Postgres / MySQL / SQLite flavor), Mongoose for Node.js MongoDB apps, or Sequelize for Node.js relational apps.

  3. 3

    Name the table or model

    Sets the table name in the SQL output, or the schema / model name in the Mongoose and Sequelize output.

  4. 4

    Copy the generated schema

    Paste it straight into a migration or a model file as a starting point.

How types are inferred

Inference is a best-guess. The tool reads the values of one sample object and picks a column type for each key from the value it sees. It does not compare records or learn which fields are optional, so give it a complete, representative object.

Type mapping

JSON value SQL type Mongoose type Sequelize type
42 (integer) INTEGER Number DataTypes.INTEGER
3.14 (decimal) DECIMAL(10,2) Number DataTypes.FLOAT
"hello" (short string) VARCHAR(255) String DataTypes.STRING
string longer than 255 chars TEXT String DataTypes.STRING
"2026-04-18T10:00:00Z" TIMESTAMP Date DataTypes.DATE
"2026-04-18" DATE Date DataTypes.DATEONLY
true / false BOOLEAN Boolean DataTypes.BOOLEAN
null TEXT String DataTypes.STRING
[1, 2, 3] (array) JSON Object DataTypes.JSON
{ "nested": ... } (object) JSON Object DataTypes.JSON

What the SQL output adds

The SQL CREATE TABLE always starts with an auto-increment primary key:

id INTEGER PRIMARY KEY AUTOINCREMENT,

The Mongoose and Sequelize output do not add an id field, because both libraries create one for you.

Defaults and limits to keep in mind

  • One object is read. If you paste an array, only the first element is inspected, so its fields define the whole schema.
  • A missing key is an absent column. Fields that are not present in the sample object simply do not appear in the output.
  • Nested objects and arrays become a single JSON column. The tool does not expand them into sub-tables, sub-schemas or foreign keys.
  • No constraints are generated. Columns are emitted without NOT NULL, unique or index clauses, so all of them are nullable until you tighten them.

Tips for a cleaner result

  • Use a fully populated record. A field that is null in your sample is typed as text/string, which is rarely what you want.
  • Rename reserved words after generation. Fields like type, order or user will need quoting in SQL.
  • Treat the output as a scaffold. Tighten VARCHAR lengths and DECIMAL precision, add indexes, mark columns NOT NULL, and pick real keys before shipping.

Frequently Asked Questions

A nested object or an array is mapped to a single JSON column (JSON in SQL and Sequelize, an Object field in Mongoose). The tool does not expand nested structures into sub-tables or sub-schemas, so you flatten or normalise them yourself if you need to.

No. If you paste an array of objects, only the first object is inspected and its keys define the schema. Make sure that first record has every field you care about, with a real value in each one.

No. Every column is emitted with just a type, so the output has no foreign keys, unique constraints, indexes or NOT NULL clauses. Add those by hand, because they encode intent the tool cannot recover from a sample.

Pick SQL CREATE TABLE for a relational database migration, Mongoose Schema for a Node.js app on MongoDB, or Sequelize Model for a Node.js app on a relational database through the Sequelize ORM.

Related Tools

Tool available in other languages