# JSON to SQL Converter - CREATE TABLE and Bulk INSERT Online

> Convert JSON arrays or CSV to SQL: inferred types and primary key, CREATE TABLE, batched INSERT and UPSERT for MySQL, PostgreSQL, SQLite, SQL Server, Oracle.

- URL: https://qilingtools.com/en/json-to-sql
- Category: Developer Tools (https://qilingtools.com/en/dev)
- Tags: [Converters](https://qilingtools.com/en/tags/convert), [Developer](https://qilingtools.com/en/tags/dev), [Data Formats](https://qilingtools.com/en/tags/data)
- Last updated: 2026-10-26
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

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.

## How to use

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

## Features

- Column types, precision, length, nullability and uniqueness inferred across all rows
- Automatic primary key guess, or pick one / none
- MySQL, PostgreSQL, SQLite, SQL Server and Oracle dialects
- Dialect-correct escaping of quotes, backslashes, Unicode and long text
- CREATE TABLE (optional DROP and IF NOT EXISTS) and batched multi-row INSERT
- UPSERT via ON DUPLICATE KEY, ON CONFLICT or MERGE
- Nested objects flattened into columns or stored as JSON
- Reverse: parse INSERT statements (including Oracle INSERT ALL) into JSON

## 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.

## Related tools

- [JSON Formatter](https://qilingtools.com/en/json): Free online JSON formatter: beautify or minify, validate with the exact line and column of any error, browse a collapsible tree, sort keys and escape strings.
- [Base64 Encode/Decode](https://qilingtools.com/en/base64): Free online Base64 encoder and decoder: UTF-8 safe, optional URL-safe variant, convert text to Base64 and back in real time. Processed locally, never uploaded.
- [URL Encode/Decode](https://qilingtools.com/en/url-encode): Free online URL encoder and decoder with encodeURIComponent and encodeURI modes. Escapes Chinese, spaces and special characters. Real-time and local, no upload.
- [JWT Decoder](https://qilingtools.com/en/jwt): Free online JWT decoder: decode the header and payload of a JSON Web Token, show expiry and issued-at times, all locally without uploading the token.
- [Timestamp Converter](https://qilingtools.com/en/timestamp): Free online Unix timestamp converter: convert timestamps and dates, auto-detect seconds or milliseconds, and show local, UTC, ISO 8601 and relative time.
- [Hash / Checksum](https://qilingtools.com/en/hash): Free online hash calculator: SHA-1, SHA-256, SHA-384 and SHA-512 of text or any file through the browser crypto API. Files never leave your device.
- [UUID Generator](https://qilingtools.com/en/uuid): Free online UUID generator: create RFC 4122 UUID v4 in bulk with a cryptographic RNG. Options for uppercase, no hyphens and braces, with one-click copy.
- [Base Converter](https://qilingtools.com/en/base-convert): Free online number base converter: convert between binary, octal, decimal, hexadecimal and any base 2–36. Uses BigInt for huge integers, computed locally.
