JSON to SQL Schema Converter
Convert JSON objects to CREATE TABLE SQL statements with automatic type inference for MySQL, PostgreSQL, and SQLite.
About This Tool
The JSON to SQL Schema Converter is a free browser-based utility that transforms JSON data into ready-to-use CREATE TABLE SQL statements. Whether you are designing a database schema from an API response, prototyping a data model from sample data, or generating migration scripts from JSON fixtures, this tool saves you from writing tedious DDL by hand.
The tool supports three SQL dialects: MySQL, PostgreSQL, and
SQLite. Each dialect uses its own type system and syntax
conventions, so the generated SQL is ready to paste directly into
your database client or migration file. MySQL uses backtick
quoting and types like TINYINT(1) for booleans,
PostgreSQL uses double-quoted identifiers with
BOOLEAN and JSONB, and SQLite uses
simplified types like TEXT, INTEGER,
and REAL.
Nested JSON objects and arrays are handled intelligently. You can choose to flatten nested objects into separate related tables with foreign key constraints, or store them as JSON columns. Arrays can be modeled as junction tables for proper normalization or stored as JSON column types. This flexibility lets you match the output to your preferred database design patterns.
All processing happens entirely in your browser using native JavaScript. Your data never leaves your machine — there are no server round-trips, no logging, and no third-party services involved. The tool also features automatic type inference across all rows, optional primary keys with auto-increment, timestamp columns, NOT NULL constraints, foreign key indexes, and syntax-highlighted output for easy reading.
How to Use
- Paste a JSON object or array of objects into the Input panel. Click Sample to load example data.
- Set the Root Table Name to match your desired database table name (default:
my_table). - Choose the SQL Dialect that matches your database (MySQL, PostgreSQL, or SQLite).
- Enable optional features like Add PRIMARY KEY, Add timestamps, NOT NULL constraints, and Foreign key indexes.
- Choose how nested objects and arrays should be handled: as separate tables with foreign keys, or as JSON columns.
- Click Copy to copy the generated SQL to your clipboard, or Download to save it as a
.sqlfile. - Keyboard shortcuts: Ctrl+Shift+C to copy the output.
Popular JSON to SQL Schema Examples
FAQ
Is my data sent to a server?
No. All conversion happens entirely in your browser using JavaScript. Your JSON data never leaves your machine. There are no network requests, no logging, and no third-party services involved. This makes it safe to convert files containing credentials, customer data, or any other sensitive information.
How does type inference work across SQL dialects?
The tool analyzes the values in your JSON to determine the best SQL type. Strings map to VARCHAR(255), integers to INT/INTEGER, floats to DECIMAL(10,2)/NUMERIC(10,2)/REAL, booleans to BOOLEAN/TINYINT(1)/INTEGER, and null values mark columns as nullable. Each dialect uses its native types: MySQL uses TINYINT(1) for booleans and DATETIME for timestamps, PostgreSQL uses BOOLEAN and TIMESTAMPTZ, and SQLite uses INTEGER for booleans and TEXT for most types.
What keyboard shortcuts are available?
Ctrl+Enter re-processes the input and Ctrl+Shift+C copies the generated SQL to your clipboard.
Related Tools
JSON to SQL INSERT
Convert JSON arrays to SQL INSERT statements. Supports bulk inserts, table name customization, and multiple SQL dialects.
SQL Formatter
Format, beautify, and minify SQL queries with dialect support for MySQL, PostgreSQL, and SQLite.
SQL to Prisma Schema
Convert SQL CREATE TABLE statements to Prisma schema models. Supports common SQL types and relations.
JSON to TypeScript
Generate TypeScript interfaces or type aliases from JSON with nested type inference.
ERD Editor
Design entity-relationship diagrams visually with drag-and-drop. Export as SVG, PNG, or SQL CREATE TABLE.
JSON to Bulk INSERT
Convert JSON arrays to optimized bulk SQL INSERT statements with batch sizing, dialect support, and column mapping.