Cryonel

JSON to SQL Converter

Convert a JSON object or array of objects into PostgreSQL CREATE TABLE and INSERT statements. The conversion runs locally in your browser.

How to use it

  1. Paste one JSON object for a single row, or an array of objects for multiple rows.
  2. Enter the destination table name. It is safely quoted in the generated SQL.
  3. Select Generate SQL or press Ctrl/ + Enter.
  4. Review the inferred schema, constraints, and values before running the script against a database.

JSON to PostgreSQL example

The converter accepts a single object or a list of row-shaped objects:

[
  {"id": 1, "name": "Ada", "active": true},
  {"id": 2, "name": "Grace", "active": false}
]

That sample becomes one table definition and one multi-row insert. Columns are collected across every object, so a property that appears in only one row is still included. A row that omits that property receives NULL in the generated values list.

PostgreSQL type inference

JSON booleans become BOOLEAN, integers become BIGINT, decimal numbers become DOUBLE PRECISION, and strings become TEXT. Objects and arrays become JSONB. When a column contains both integers and decimal values, the converter chooses DOUBLE PRECISION. Incompatible mixed types fall back to TEXT.

A column containing only null values also becomes TEXT, because null does not reveal its intended database type. This is a safe placeholder, not a claim about the production schema. Change it to the domain’s real type before creating the table.

Identifier and value escaping

Table and column identifiers are wrapped in PostgreSQL double quotes, and embedded double quotes are escaped. Text values use single quotes with internal apostrophes doubled. Nested JSON is serialized and cast to jsonb. These rules keep the generated script syntactically safe for the pasted data, but they do not replace application-level parameterized queries.

Do not build runtime queries by concatenating user input. For application code, use the parameter binding provided by your database driver. This tool is intended for one-time imports, fixtures, migration drafts, and schema exploration where the generated SQL will be reviewed before execution.

What the sample cannot infer

A JSON sample cannot discover primary keys, unique constraints, foreign keys, indexes, generated columns, length limits, numeric precision, default values, or required fields. It also cannot prove that every future value uses the same type. Add those database rules from the real domain model rather than guessing from one payload.

Large data migrations should use PostgreSQL’s bulk-loading tools or an ETL process instead of a massive hand-reviewed insert statement. This converter is most useful for small samples and for creating a clear starting point.

Security and privacy

Parsing and SQL generation happen entirely in the current browser tab. Cryonel does not upload the JSON or SQL output. The generated script may still contain private values from your sample, so treat downloaded files and copied snippets with the same care as the source data.

Frequently Asked Questions

Which SQL dialect does this converter generate?

It generates PostgreSQL SQL, including double-quoted identifiers and JSONB values.

Can it convert a JSON array into multiple rows?

Yes. Every array item must be a JSON object. Missing properties become NULL in the generated row.

Is the generated SQL safe to run immediately?

Review it first. Type inference from a sample cannot discover keys, constraints, indexes, relationships, or every production value shape.

Related Tools