Toolvore

JSON to SQL

Generate SQL INSERT statements from flat JSON records, preserving numeric text, nulls and omitted fields.

This tool processes its input contents in your browser instead of sending them to a processing service. Page, asset and fixed usage-measurement requests are described on the Privacy page.

Generate dialect-specific INSERT text from flat JSON records, retaining numeric spellings and distinguishing missing keys from explicit null.

How to use it

  1. 1Paste one object or an array of flat objects, or open a local UTF-8 JSON file.
  2. 2Choose the existing table name and SQL dialect, then generate SQL.
  3. 3Review numeric types, defaults, constraints and each INSERT before copying or downloading.

Example

Input
[{"id":9007199254740993,"note":null},{"id":2}]
Output
Two INSERTs: the first has explicit NULL; the second omits note.

The numeric token is retained; receiving database types still control storage.

What happens to your data

No database connection or upload. JSON, SQL, identifiers and filenames stay in tab memory and are excluded from fixed usage measurements.

Last updated November 2026

Turn one JSON object or an array of flat records into SQL INSERT statements for SQLite, PostgreSQL or MySQL. Choose the target table, review the generated statements and copy or download the SQL file. The converter works locally and never connects to a database. It is useful for preparing small data imports, fixtures or a reviewable starting point for a migration without manually retyping each value.

How it works

Every object produces one INSERT statement with that object's own column list. JSON strings become dialect-quoted SQL strings, booleans become TRUE/FALSE (1/0 in SQLite), and explicit JSON null becomes SQL NULL. If a key is absent from an object, its column is omitted from that row's statement; the target table's default or null behavior applies. An empty object uses DEFAULT VALUES in SQLite/PostgreSQL or an empty-column INSERT in MySQL. No CREATE TABLE statement, guessed schema, update, overwrite or execution is performed.

The existing JSON lexer retains original numeric tokens, including integers larger than JavaScript's safe integer range. The converter does not round those tokens through Number. This is a text guarantee only: a database's existing numeric column type, range, precision, scale or affinity can still reject, round or coerce the value. Numbers are bounded to 1,024 digits and exponents from −1,000 to 1,000. Review the receiving schema before running any generated file.

Object keys remain own data properties, including __proto__ and constructor. Duplicate decoded keys are rejected rather than selecting a winner. Nested arrays/objects are rejected so flattening or storing JSON text is a deliberate separate decision. SQLite/MySQL column names must also be distinct ignoring case across every record. Table/column identifiers are bounded to 63 UTF-8 bytes, reject controls and use the selected dialect's quoting rules. MySQL adds its supplementary-character and trailing-space restrictions. A dot in the table field remains part of one quoted name; schema qualification is not inferred. Strings containing NUL or unpaired surrogates are rejected.

SQLite strings use doubled apostrophes. PostgreSQL strings use explicit escape-string notation with escaped backslashes. MySQL text uses a UTF-8 hexadecimal conversion so its handling does not depend on backslash SQL mode. These choices preserve supported text; they do not make executing an arbitrary data import risk-free. Use your intended database, inspect constraints/triggers and keep a backup where appropriate.

Input is limited to 2 MiB, 5,000 objects, 200 distinct columns, 200,000 supplied cells, eight nesting levels and 100,000 JSON tokens. Output is bounded to 10 MiB; a limit rejects the conversion as a whole. Editing input or settings removes old output, and Clear discards an in-flight result. Source text, identifiers, values and filenames stay in tab memory and are excluded from fixed usage measurements.

Worked example: Omission and null stay different

Input
[{"id":9007199254740993,"note":null},{"id":2}] with SQLite/table records
Result
INSERT INTO "records" ("id", "note") VALUES (9007199254740993, NULL); INSERT INTO "records" ("id") VALUES (2);

The first ID is retained as text in SQL; target database types still determine storage.

Common use cases

  • Prepare INSERT statements from a trusted API's flat JSON response.
  • Preserve long identifier spellings while reviewing the target numeric column type.
  • Keep explicit null and absent optional fields distinct during fixture preparation.
  • Generate dialect-specific SQL text without installing a database client or uploading records.

Frequently asked questions

Does this create a table or run SQL?+

No. It produces INSERT text only. The table must already exist with compatible columns/defaults. Copying or downloading SQL does not execute it.

What is the difference between a missing key and null?+

An explicit null is exported as SQL NULL. A missing key is omitted from that object's column list, allowing the existing table's default behavior to apply. They are not silently merged.

Will long numeric IDs keep all their digits?+

The generated SQL retains the original JSON numeric spelling without JavaScript number conversion. Your database's target type may still round, coerce, overflow or reject it, so review that schema before executing the export.

Can nested arrays or duplicate keys be converted?+

No. This tool accepts scalar columns only and rejects duplicate decoded object keys. Flatten nested data deliberately or decide how JSON should be stored before generating SQL.

Is private JSON sent to a server?+

No. Conversion and file reading happen in this tab. Optional usage measurement records fixed job outcomes and result actions, not source text, keys, values, table names or filenames.