QiLing Tools

🛢️JSON to SQL Converter - CREATE TABLE and Bulk INSERT Online

Need API responses, scraped data or a spreadsheet export in a database for testing or analysis? Paste a JSON array (or a single object, a { "data": [...] } wrapper or a 2-D array) or CSV with a header row, and every row is scanned to infer each column’s type — integer, big integer, decimal with precision and scale, float, boolean, date, datetime with or without a time zone, string length or JSON — along with nullability and uniqueness, and a primary key is guessed (id, table_id and so on). You can override any column’s type. Nested objects can be flattened into prefix_field columns or kept as a single JSON column. Five dialects are supported — MySQL, PostgreSQL, SQLite, SQL Server and Oracle — each with the right identifier quoting, type names, boolean literals and JSON type, and strings escaped the way that database expects (backslashes in MySQL, the N prefix in SQL Server, long Oracle strings split into TO_CLOB pieces). Generate DROP / CREATE TABLE, multi-row INSERTs in batches of your chosen size, or UPSERTs: ON DUPLICATE KEY UPDATE for MySQL, ON CONFLICT for PostgreSQL and SQLite, and MERGE for SQL Server and Oracle. It works in reverse too: paste INSERT statements and get JSON back. Your data stays in your browser.

Free · No sign-up · Runs in your browserLast updated:

Loading tool...

How to use JSON to SQL Converter

  1. 1Paste a JSON array or CSV, or open a .json / .csv file
  2. 2Choose the dialect, table name, primary key, nested-object handling and INSERT / UPSERT mode, and adjust column types if needed
  3. 3Copy or download the SQL; switch to SQL INSERT → JSON for the reverse

FAQ

How are column types inferred?
Each column is checked across every row: all integers become INT (BIGINT beyond about 2.1 billion), decimals become DECIMAL(p,s) sized to the largest integer and fraction parts, true/false is boolean, strings like 2024-01-31 are dates, ones with a time are DATETIME / TIMESTAMP (TIMESTAMPTZ in PostgreSQL when a zone is present), objects and arrays are JSON, and everything else is VARCHAR rounded up from the longest value, or TEXT. Columns with null or missing values are nullable. CSV values with leading zeros such as 007 stay strings.
Will the generated SQL run as is?
Yes. Strings are escaped by the target database’s rules — MySQL escapes backslashes, PostgreSQL only doubles single quotes, SQL Server uses the N prefix to keep Unicode. We ran the generated CREATE TABLE, INSERT and UPSERT statements on SQLite and PostgreSQL. For very large data, lower Rows per INSERT to stay under limits such as max_allowed_packet.
How are nested JSON objects handled?
By default nested objects are flattened, so address.city becomes an address_city column (the separator is configurable); arrays are always stored as JSON. Alternatively store each nested object as one JSON column — JSON in MySQL, JSONB in PostgreSQL, and text with a JSON check constraint in SQL Server and Oracle.
How do I turn INSERT statements back into JSON?
Switch to SQL INSERT → JSON and paste one or more INSERT statements. Backtick, double-quote and bracket identifiers, multi-row VALUES, N'…', E'…' and X'…' strings and Oracle INSERT ALL are supported, and multiple tables are grouped by name. Keep “Backslash is an escape character” checked for MySQL dumps.