JSON → MySQL

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

What is JSON → MySQL?

Convert JSON to MySQL 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.

MySQL types are used where they fit: VARCHAR(255) for short strings and TEXT for long ones, JSON for nested data and lists, DATETIME for timestamps (converted to UTC when the value has a zone), CHAR(36) for UUIDs, and AUTO_INCREMENT for generated keys. Backslashes and quotes in values are escaped the way MySQL expects.

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 MySQL. Everything runs in your browser, so your data never leaves your machine.

Features

  • CREATE TABLE statements in MySQL 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 → MySQL

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

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

-- MySQL schema generated by JSON PowerHouse

CREATE TABLE IF NOT EXISTS users (
    id INT NOT NULL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    email VARCHAR(255) NOT NULL,
    signed_up_at DATETIME NOT NULL
);

CREATE TABLE IF NOT EXISTS address (
    id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL UNIQUE,
    city VARCHAR(255) NOT NULL,
    FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS orders (
    id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    sku VARCHAR(255) NOT NULL,
    qty INT NOT NULL,
    FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
);

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

-- MySQL schema generated by JSON PowerHouse

CREATE TABLE IF NOT EXISTS users (
    id INT NOT NULL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    active BOOLEAN NOT NULL
);

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

Frequently asked questions

How do I convert JSON to a MySQL table?

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

Which MySQL types does it use?

INT or BIGINT for whole numbers, DOUBLE for decimals, BOOLEAN, VARCHAR(255), TEXT or LONGTEXT depending on length, DATE, DATETIME, CHAR(36) for UUIDs, and JSON for nested data and lists. Generated keys use BIGINT AUTO_INCREMENT. The statements are written for MySQL 8.

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.