What does a JSON or CSV to CREATE TABLE tool do?
You have a list of records in JSON or a CSV exported from a spreadsheet, and you want it in a database. Writing the CREATE TABLE by hand means looking at every column, guessing the type and typing the INSERT statements. This tool does that for you. Paste a JSON list of objects or a CSV with a header row, choose PostgreSQL, MySQL, SQLite or SQL Server, and get the CREATE TABLE plus the INSERT with the data.
The type of a column comes from all its values, not from the first row. A column with 1 and 2.25 becomes a decimal wide enough for both. An integer beyond 32 bits becomes BIGINT. A mix of numbers and words is text. Dates, timestamps and booleans are recognized, and each dialect gets its own type: a boolean is BOOLEAN in PostgreSQL and MySQL, BIT in SQL Server and INTEGER in SQLite. Text columns get a VARCHAR length with room to spare, and very long text becomes TEXT or NVARCHAR(MAX). A nested array or object is stored as JSONB in PostgreSQL and JSON in MySQL, and as text elsewhere.
You can control some choices: the table name, NOT NULL where no value is missing, primary key detection when an id column is unique, snake_case column names, exact decimals and whether to write the INSERT rows. Names that are reserved words in some dialect are quoted. The tool does not create indexes or foreign keys, and it cannot know what your data means, so read the result before you run it. Everything is done in your browser, and your data is never uploaded.
How to create a table from JSON or CSV
- Paste a JSON list of objects, for example
[{"id": 1}, {"id": 2}], or a CSV whose first line holds the column names. A button loads a CSV example. - Choose the database.
- Type the table name.
- Turn the options on or off:
INSERTrows,NOT NULL, primary key detection,snake_casenames and exact decimals. - Read the summary line, which shows the number of rows and columns and whether the source was read as JSON or CSV.
- Copy the SQL and run it in your database client. Try it on a copy of the data first.
Examples
JSON to PostgreSQL
Input:
[
{ "id": 1, "Full Name": "Ana Souza", "email": "ana@example.com", "balance": 1250.5, "vip": true, "joined": "2026-01-15", "last_seen": "2026-11-21T14:03:00Z", "tags": ["a", "b"], "referrer": null },
{ "id": 2, "Full Name": "Bruno O'Neil", "email": "bruno@example.com", "balance": 80, "vip": false, "joined": "2026-03-02", "last_seen": "2026-11-20T09:30:00Z", "tags": [], "referrer": 1 }
]Output:
CREATE TABLE customers (
id INTEGER NOT NULL,
full_name VARCHAR(16) NOT NULL,
email VARCHAR(32) NOT NULL,
balance NUMERIC(5, 1) NOT NULL,
vip BOOLEAN NOT NULL,
joined DATE NOT NULL,
last_seen TIMESTAMPTZ NOT NULL,
tags JSONB NOT NULL,
referrer INTEGER,
PRIMARY KEY (id)
);
INSERT INTO customers (id, full_name, email, balance, vip, joined, last_seen, tags, referrer) VALUES
(1, 'Ana Souza', 'ana@example.com', 1250.5, TRUE, '2026-01-15', '2026-11-21T14:03:00Z', '["a","b"]', NULL),
(2, 'Bruno O''Neil', 'bruno@example.com', 80, FALSE, '2026-03-02', '2026-11-20T09:30:00Z', '[]', 1);Full Name became full_name. The referrer column is nullable because one row has null, and id is the primary key because its values are unique. The apostrophe in O'Neil is doubled in the INSERT.
CSV to MySQL
Input:
id,full_name,email,balance,vip,joined
1,Ana Souza,ana@example.com,1250.50,true,2026-01-15
2,Bruno O'Neil,bruno@example.com,80.00,false,2026-03-02With the table name clientes:
CREATE TABLE clientes (
id INTEGER NOT NULL,
full_name VARCHAR(16) NOT NULL,
email VARCHAR(32) NOT NULL,
balance DECIMAL(6, 2) NOT NULL,
vip BOOLEAN NOT NULL,
joined DATE NOT NULL,
PRIMARY KEY (id)
);
INSERT INTO clientes (id, full_name, email, balance, vip, joined) VALUES
(1, 'Ana Souza', 'ana@example.com', 1250.50, TRUE, '2026-01-15'),
(2, 'Bruno O''Neil', 'bruno@example.com', 80.00, FALSE, '2026-03-02');In the CSV the text 1250.50 has two decimals, so the column is DECIMAL(6, 2) and the value keeps its trailing zero. In the JSON above, the number 1250.5 has only one, so the column was NUMERIC(5, 1). The type reflects what is written in the data.
The same data, SQL Server and SQLite
For [{"id":1,"n":2.5,"d":"2026-01-02","ok":true},{"id":2,"n":10,"d":"2026-02-03","ok":false}], SQL Server gives:
CREATE TABLE t (
id INT NOT NULL,
n DECIMAL(3, 1) NOT NULL,
d DATE NOT NULL,
ok BIT NOT NULL,
PRIMARY KEY (id)
);and SQLite gives:
CREATE TABLE t (
id INTEGER NOT NULL,
n REAL NOT NULL,
d TEXT NOT NULL,
ok INTEGER NOT NULL,
PRIMARY KEY (id)
);SQLite has no date or boolean type, so they are stored as text and as 0 and 1.
Common mistakes
- Pasting a JSON object that is not a list. The input must be a list of objects, one per row, such as
[{"id": 1}, {"id": 2}]. If you paste something else, the message shows that form. - A CSV with no data row. A header alone is not enough. The CSV needs the header and at least one row.
- An open quote in a CSV field. The message gives the line. Close the quote, or remove a stray one.
- Trusting the types blindly. The tool sees only your sample. A column where every row happens to be short is given a short
VARCHAR, and a code such as007stays text because of the leading zeros. A date that does not exist, such as 2026-02-30, is also text. - Expecting constraints it cannot know. Foreign keys, indexes, defaults and uniqueness beyond the primary key are not generated. Add them by hand.
- Running the
INSERTon a huge file. The result is one statement with all the rows, which is fine for samples and tests. For a large load, use your database's bulk import.
Frequently asked questions
Where do the column types come from?
From every value of the column. Integers, decimals, booleans, dates and timestamps are recognized, and anything mixed falls back to text. An empty CSV field counts as NULL.
Why is a column NOT NULL or nullable?
It is NOT NULL only if no row has null or is missing the key. One missing value is enough to make it nullable.
Does it send my data to a server?
No. Parsing, typing and writing the SQL all happen in your browser.
Can I work with the data before I create the table?
Yes. Convert an Excel file with Excel or CSV to JSON, reshape columns with the CSV tools, and tidy the final statement with SQL prettify.