JSON to SQL

Turn an array of records into CREATE TABLE and INSERT statements. Check the column types before running them.

JSON to SQL

Data & Format Tools

Runs locally in your browser.

Runs locally in your browser — your JSON is converted on your device and never uploaded.

About the JSON to SQL

Moving data from loosely-typed JSON structures (e.g. REST API response bodies) and NoSQL document stores into SQL databases takes patience. Developers have to painstakingly analyze the incoming JSON to deduce what database schema to use, write CREATE TABLE statements, and then carefully format SQL INSERT statements while properly escaping special characters.

This JSON to SQL converter takes away all this drudgery. With just a few button clicks, developers can paste their JSON array input, review suggested column types, and generate production-ready SQL queries. Strictly privacy-focused, this JSON to SQL utility does not send any data to servers over the network.

Key Features of JSON to SQL

  • Schema Generation (CREATE TABLE)Easily define database table schemas by simply pasting your JSON array input. The utility will smartly guess the most appropriate column type (VARCHAR, INT, FLOAT, BOOLEAN etc) for each attribute.
  • Bulk Inserts (INSERT)Instantly generate SQL insert statements from your JSON array.
  • Table NamingSpecify your desired table name or leave it blank (default: users).
  • PrivacyYour data is processed entirely in the browser with no data sent over the network.

How to Use JSON to SQL

  1. Open the JSON to SQL converter page
  2. Paste your JSON array (array of objects) in the JSON input textarea.
  3. Type the desired SQL table name in the Table name field
  4. Check the Output dropdown to select your desired SQL query type. You can choose to generate only inserts (not the CREATE TABLE command) by choosing the appropriate option from the dropdown. This is useful if you want to append data to an existing table.
  5. Click the purple "Generate" button and wait for the SQL queries to appear in the output below.
  6. Click "Copy" to copy the generated SQL code to your clipboard or "Download" to save it to your computer as a .sql file.

JSON to SQL Examples

Two records turned into SQL. Note how the apostrophe in a name is escaped; review statements before running them on real data.

Input
[{"id":1,"name":"Amal"},{"id":2,"name":"O'Brien"}]
Result
CREATE TABLE IF NOT EXISTS "users" (
  "id" INTEGER,
  "name" TEXT
);

INSERT INTO "users" ("id", "name") VALUES
  (1, 'Amal'),
  (2, 'O''Brien');

JSON to SQL — Frequently Asked Questions

How does it know which SQL type to use for which column?
The utility will analyze the values within each column of your JSON array and try to guess the most appropriate SQL type. For example, it will use VARCHAR for strings, INT for integers, FLOAT for decimals, and BOOLEAN for boolean values.
Can I generate just the INSERT statements and not the CREATE TABLE command?
Yes, simply select the desired option from the Output dropdown.
Isn't it dangerous to paste my JSON data here? After all, this is a public web app.
Your JSON data is processed locally inside your browser. The JSON to SQL utility does not send any data over the network, so your information is safe.