Skip to content
100% local

JSON to SQL CREATE TABLE

Turn a JSON object or array of objects into a SQL CREATE TABLE statement.

Input
Output

JSON to SQL CREATE TABLE

Paste a JSON object, or an array of JSON objects, and this tool builds a ready-to-run SQL CREATE TABLE statement from it — point it at a sample API response or an exported record and get a starting schema instead of typing every column by hand.

Column types are inferred from the actual values: whole numbers become INTEGER, numbers with a fractional part become DECIMAL, true/false becomes BOOLEAN, strings shaped like 2024-01-15 or 2024-01-15T10:30:00Z become DATE or TIMESTAMP, and everything else becomes VARCHAR with an estimated length, or TEXT past 255 characters. A field marked NOT NULL is one that is present, and never null, in every record pasted; a field named id becomes the PRIMARY KEY. Pick a dialect — ANSI SQL, MySQL, PostgreSQL, SQLite or SQL Server — to match the small differences in type names. Nested objects can be flattened into prefixed columns (address.city becomes address_city) or kept as a single JSON column, and "Convert names to snake_case" turns camelCase JSON keys into conventional SQL column names.

With more than one record, turning on "Add INSERT statements" appends one INSERT per record beneath the CREATE TABLE, using the same inferred columns — handy for seeding a test database from a JSON fixture. Inference always looks across every record supplied, not just the first, so a field only sometimes present is correctly left nullable rather than guessed wrong.

Everything runs in your browser. The JSON you paste, and the schema generated from it, are never uploaded anywhere — that matters when the sample data comes from a production export. Copy the result, download it as a .txt file, or send the output back into the input to keep refining the schema.

FAQ

How are column types decided?
Each column is inferred from every value seen for that field across all the records you pasted — not just the first one. A field with mixed types (a number in one record, a string in another) falls back to a text column, since that is the only type that can safely hold both.
What happens to a field named "id"?
A column named id (after snake_case conversion, if enabled) becomes the PRIMARY KEY. Auto-increment or identity syntax differs enough between dialects that it is left out — add it yourself once you have picked a strategy.
What is the difference between the two nested-object options?
"Flatten with underscore" turns a nested object like address: { city } into a separate address_city column. "Keep as a JSON column" stores the whole nested object as one JSON (or text) column instead. Arrays are always kept as a single JSON/text column, since a single row cannot hold a variable-length list.
Can it generate data to insert as well as the table?
Yes. Turn on "Add INSERT statements" and, if you pasted an array of objects, one INSERT statement per record is appended beneath the CREATE TABLE, using the columns and types already inferred.
Is my JSON uploaded anywhere?
No. Parsing, type inference and SQL generation all run locally in your browser — your JSON and the schema derived from it never leave your device.