JSON to SQL Generator
Generate CREATE TABLE and INSERT statements from a JSON array. Infers column types and safely escapes string values. Runs entirely in your browser.
JSON array
How it works
- Paste a JSON array of objects — keys become columns, and types are inferred across all rows (integer →
INTEGER, float →REAL/DOUBLE, string →TEXT/VARCHAR, boolean →BOOLEAN). - Nested objects/arrays become
TEXTcolumns holding the JSON-encoded value. - String values are escaped by doubling single quotes; booleans become
TRUE/FALSE. - Missing keys are emitted as
NULL, so every row has the same column set.
About JSON to SQL Generator
When you receive data as JSON — an export, an API response, a fixture — but need it in a relational database, writing the DDL and INSERT statements by hand is tedious and error-prone. This tool derives the table structure from the data itself: every key becomes a column, and the type for each column is decided by looking at the values across all rows, so one stray string doesn’t make the whole column TEXT.
The generated statements target common dialects (MySQL, SQLite, PostgreSQL) and are safe to run: identifiers are validated, string literals are single-quote-escaped, and NULLs are explicit. This is a great way to seed test databases, convert spreadsheet-derived JSON, or move fixture data into SQL. For production use, review the column widths and add primary keys, constraints, and indexes — this tool focuses on getting the data in.