Convert flat JSON and SQL data locally
Convert flat JSON rows to a documented PostgreSQL or SQLite SQL subset, or import supported CREATE TABLE and INSERT literals as JSON.
Tool workspace
JSON ↔ SQL converter
JavaScript is required to process files locally in your browser. No data is sent to a server.
Convert flat JSON rows to SQL or import a published SQL subset as JSON. Conversion starts only when you choose the action.
Your input stays in this browser. Files are read locally and are never uploaded.
This tool implements a documented subset and reference profile, not a complete database engine. Reference: PostgreSQL {version}; UTF8 and standard_conforming_strings enabled.
JSON must contain flat rows made from objects with scalar values. SQL accepts one table, published scalar types, and INSERT statements with complete column lists.
SQL is generated as text using the selected dialect profile. No SQL is executed.
Limits: input 1,000,000 UTF-16 units / 4,000,000 bytes; file 4,000,000 bytes; rows 10,000; columns 200; cell positions 75,000.
The profile also bounds SQL statements, tokens, parsing work, output size, diagnostics, and operation time. Remaining input units and bytes are shown below.
The example is a local fixture. Loading it replaces the input after your explicit action.
JavaScript is required to process files locally in your browser. No data is sent to a server.
Messages and diagnostics
Messages identify the SQL statement, tuple, table column, or physical editor position when available. Unknown internal details are hidden.
Some diagnostic details were omitted to stay within the display limit.
Result summary
- Dialect profile
- Table
- Rows
- Columns
- SQL statements
- Observed to SQL types
| Column | Observed or source type | SQL type | Declared SQL type | Nullable |
|---|
This read-only preview is capped. Copy and download use the complete current result.
The preview is limited to {maxPreviewCodeUnits} UTF-16 units. The complete output remains available to copy or download.
Copy manually
Clipboard access is unavailable. Select and copy the complete result below.
Convert flat JSON rows to SQL
Choose JSON to SQL, paste a JSON array of row objects (or one row object), select PostgreSQL or SQLite, and press Generate SQL. The tool takes the union of keys across all rows and writes them in first-seen order. Each object contributes one row. Cell values must be strings, finite numbers, booleans, or null; nested arrays and objects are rejected.
[
{"id": 1, "name": "Ada", "active": true},
{"id": 2, "name": "Grace", "active": false}
]
An explicit null is a value. A missing property is different: the default is to reject it. The optional Convert missing values to NULL setting fills the absent cell, but loses the distinction between an absent property and explicit null. Columns with incompatible value families, such as a number in one row and an object in another, are rejected. A column containing only nulls has no certain inferred type and is reported.
The PostgreSQL reference profile emits TEXT, BIGINT, NUMERIC, and BOOLEAN. SQLite emits TEXT, INTEGER, REAL, and BOOLEAN; SQLite stores booleans as integers, and REAL may round decimal values. CREATE TABLE is included by default and can be omitted; generated SQL still contains INSERT statements. Identifiers follow the selected dialect’s rules, including reserved words and a 63-byte identifier limit. SQL string literals are quoted by the writer. Nothing is sent to a database or executed.
Import the supported SQL subset as JSON
Choose SQL to JSON, paste SQL or load one local .sql file, select the same dialect profile, choose 2 or 4 spaces, and press Convert to JSON. The parser accepts at most one optional CREATE TABLE followed by INSERT INTO ... (complete column list) VALUES (...) statements. It reads only literal values in VALUES; it does not evaluate SQL.
PostgreSQL accepts TEXT, BIGINT, NUMERIC, and BOOLEAN. Its reference profile requires UTF8 and standard_conforming_strings enabled; apostrophes in string literals are represented by doubling them. SQLite accepts TEXT, INTEGER, REAL, and BOOLEAN. Unsupported types, SQL queries such as SELECT, parameters, defaults, expressions, schema dumps, multiple tables, and other constructs outside the published grammar are rejected. This is not a general SQL importer and does not connect to either database.
With CREATE TABLE, its column order and names define the JSON object keys. Without it, the first INSERT column list defines their order. Later lists may reorder those same columns, but cannot add or omit a column. Every tuple must have the matching number of values, and all statements must name the same table. Any invalid statement rejects the whole input; no prefix rows are returned. Output is always a JSON array. CREATE TABLE without inserts produces [] and a notice. Table names, declared types, and SQL comments are not included in JSON, so a round trip does not preserve schema or comments and is not generally guaranteed to reproduce the original SQL.
Numeric and storage behavior
JSON and SQL numeric lexemes are checked against the local profile before output. Inputs that cannot be retained without losing numeric precision, exceed the finite supported range, or exceed the 128-character number limit are rejected. Negative zero is normalized to zero with a notice. SQLite REAL storage can round decimals, and SQLite represents booleans as integers. Review these differences when another database or consumer will read the exported text. PostgreSQL string handling is described for the required standard_conforming_strings setting; this tool does not test a live server configuration.
Complete output, preview, and limits
The editor and selected files stay in this browser. Files are read as UTF-8 locally; JSON mode accepts .json and SQL mode accepts .sql. Conversion is explicit and runs in a cancelable local Web Worker. No SQL is executed, no database connection is opened, and source text is not placed in a URL or browser storage.
The read-only preview is capped at 20,000 UTF-16 units. Copy and download use the complete output. A clipboard failure offers an explicit manual-copy view of that complete text. Downloads contain SQL or a JSON array; they do not export a relational schema or SQL comments.
The profile limits input to 1,000,000 UTF-16 units and 4,000,000 UTF-8 bytes; each file to 4,000,000 bytes; JSON depth to 200 and nodes to 100,000; rows to 10,000; columns to 200 and cell positions to 75,000; SQL statements to 1,001 and tokens to 400,000; identifier length to 63 UTF-8 bytes; output to 2,000,000 UTF-16 units and 8,000,000 bytes; operation work to 4,000,000 units and 15,000 ms; and retained diagnostics to 100. Column details and diagnostic text are also bounded. The caps apply together, so an input may reach one limit before another.
Changing input, mode, options, examples, or files clears the previous result. Clear keeps the current direction and resets that mode’s options. Errors, cancellation, timeout, and limit failures produce no partial output.