JSON → SQLite

JSON input
Loading editor...
SQLite outputLive
Loading editor...
// Generated SQLite code will appear here...

What is JSON → SQLite?

Convert JSON to SQLite tables in one step. Paste a JSON object or an array of objects and get ready-to-run CREATE TABLE statements, with column types inferred from your data, NOT NULL where every record has a value, and a primary key.

Nested objects and arrays of objects become child tables linked with foreign keys (one-to-one or one-to-many), so the schema is properly normalized. If you prefer to keep nested data together, switch the setting to store it in JSON columns instead.

SQLite type affinities are used: INTEGER for whole numbers and booleans (stored as 0 and 1), REAL for decimals, and TEXT for strings, dates, UUIDs and JSON. Generated keys use INTEGER PRIMARY KEY AUTOINCREMENT, and PRAGMA foreign_keys = ON is added when the schema has foreign keys, because SQLite does not enforce them by default.

Turn on INSERT statements to load the JSON data itself. Child rows get generated ids that link them to their parent, and values are escaped correctly for SQLite. Everything runs in your browser, so your data never leaves your machine.

Features

  • CREATE TABLE statements in SQLite syntax
  • Column types inferred from values: integers, decimals, booleans, text, dates, timestamps and UUIDs
  • NOT NULL for fields present in every record
  • Reuses a unique id field as the primary key, or adds an auto-increment key
  • Nested objects and arrays become child tables with foreign keys, or JSON columns
  • Optional INSERT statements with correct escaping
  • Reserved words such as user and order are quoted automatically
  • 100% client-side: nothing is uploaded

How to use JSON → SQLite

  1. Paste your JSON. Enter a JSON object or an array of objects. Each object becomes a row.
  2. Set the options. Open Settings to name the root table, choose child tables or JSON columns for nested data, and add INSERT statements or IF NOT EXISTS.
  3. Review the schema. Check the generated types and keys, and adjust names or lengths if your real data needs more room.
  4. Copy or download. Copy the SQL or download it as a .sql file and run it in SQLite.

Examples

Nested JSON to related tables

The root table is named users in Settings. address becomes a one-to-one child table, orders a one-to-many child table.

Input

[
  {
    "id": 1,
    "name": "Ada",
    "email": "ada@example.com",
    "signedUpAt": "2026-01-02T10:00:00Z",
    "address": {
      "city": "London"
    },
    "orders": [
      {
        "sku": "A1",
        "qty": 2
      }
    ]
  }
]

Output

-- SQLite schema generated by JSON PowerHouse

PRAGMA foreign_keys = ON;

CREATE TABLE IF NOT EXISTS users (
    id INTEGER NOT NULL PRIMARY KEY,
    name TEXT NOT NULL,
    email TEXT NOT NULL,
    signed_up_at TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS address (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id INTEGER NOT NULL UNIQUE,
    city TEXT NOT NULL,
    FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS orders (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id INTEGER NOT NULL,
    sku TEXT NOT NULL,
    qty INTEGER NOT NULL,
    FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_orders_user_id ON orders (user_id);

JSON array to INSERT statements

With INSERT statements turned on, each object becomes a row and quotes are escaped.

Input

[
  {
    "id": 1,
    "name": "Ada",
    "active": true
  },
  {
    "id": 2,
    "name": "O'Brien",
    "active": false
  }
]

Output

-- SQLite schema generated by JSON PowerHouse

CREATE TABLE IF NOT EXISTS users (
    id INTEGER NOT NULL PRIMARY KEY,
    name TEXT NOT NULL,
    active INTEGER NOT NULL
);

INSERT INTO users (id, name, active) VALUES
    (1, 'Ada', 1),
    (2, 'O''Brien', 0);

Frequently asked questions

How do I convert JSON to a SQLite table?

Paste your JSON into the input editor. The tool reads every record, works out a SQLite type for each field, and writes a CREATE TABLE statement you can run directly. Turn on INSERT statements to load the data too.

Which SQLite types does it use?

SQLite has only a few storage classes, so the tool uses INTEGER (whole numbers and booleans), REAL (decimals) and TEXT (strings, dates, timestamps, UUIDs and JSON). JSON stored as TEXT can still be queried with SQLite's built-in JSON functions.

How are nested objects and arrays handled?

By default each nested object becomes a child table with a UNIQUE foreign key (one-to-one), and each array of objects becomes a child table with a foreign key (one-to-many). Arrays of plain values become array or JSON columns. You can switch to storing all nested data in JSON columns instead.

Which column becomes the primary key?

If every record has a unique, non-null id field, it is used as the primary key. Otherwise an auto-increment id column is added.

Why is a column NOT NULL?

A column is NOT NULL when every record in your sample has a non-null value for it. Paste more varied sample data if some fields can be missing in practice.

Is my data uploaded?

No. The schema and INSERT statements are generated entirely in your browser.