How to Generate a schema.json File from Your Database

The easiest options: phpMyAdmin (MySQL/MariaDB) or Oracle SQL Developer

After exporting, save the file as schema.json and upload it to AI-SQL-Chat on the page “Upload Schema”. The generator will then create one safe SELECT query tailored to your structure. Security details are described in the Security section.

MySQL / MariaDB (phpMyAdmin) — 3 Steps

The simplest workflow in phpMyAdmin
1. Run the SQL Query (phpMyAdmin)
In phpMyAdmin open the SQL tab and paste this query. Replace your_database with the name of your schema:
simple column list
SELECT
  TABLE_NAME,
  COLUMN_NAME,
  DATA_TYPE,
  IS_NULLABLE,
  COLUMN_KEY
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'your_database'   -- <-- REPLACE
ORDER BY TABLE_NAME, ORDINAL_POSITION;
The result is a flat list: table/column/type — enough to build a JSON schema.
► Optional: MySQL 8+ Nested JSON (one-shot)

For MySQL 8+ you can build a complete JSON object with tables and columns.

SELECT JSON_OBJECTAGG(tbl.table_name, tbl.columns_json) AS schema_json
FROM (
  SELECT
    c.TABLE_NAME AS table_name,
    JSON_ARRAYAGG(
      JSON_OBJECT(
        'column', c.COLUMN_NAME,
        'type',   c.DATA_TYPE,
        'null',   c.IS_NULLABLE,
        'key',    c.COLUMN_KEY
      ) ORDER BY c.ORDINAL_POSITION
    ) AS columns_json
  FROM INFORMATION_SCHEMA.COLUMNS c
  WHERE c.TABLE_SCHEMA = 'your_database'  -- <-- REPLACE
  GROUP BY c.TABLE_NAME
) AS tbl;
2. Export the Result to JSON
  • After running the query, click Export (under the results table).
  • Select Format: JSON.
  • Save the file as schema.json.
You can now upload this file on “Upload Schema”.
3. Upload the File to AI-SQL-Chat

Go to /schema-query.html, choose the .json file and click Upload. The SQL generator will now use your schema.

The schema contains only table/column names — no data.

Oracle (SQL Developer) — 3 Steps

Metadata export to JSON (choose json-formatted!)
1. Run the Query in Worksheet
In Oracle SQL Developer connect to the DB, open a Worksheet and paste this query. Replace OWNER with your schema name (usually UPPERCASE):
all columns of all tables
SELECT
  OWNER,
  TABLE_NAME,
  COLUMN_NAME,
  DATA_TYPE,
  DATA_LENGTH,
  DATA_PRECISION,
  DATA_SCALE,
  NULLABLE
FROM ALL_TAB_COLUMNS
WHERE OWNER = 'HR'  -- <-- REPLACE WITH YOUR SCHEMA
ORDER BY TABLE_NAME, COLUMN_ID;
Not sure of your schema name? Use SELECT USER FROM dual; or SELECT username FROM all_users;
2. Export the Result to JSON
  • Right-click the results grid → Export… (or use the Export Wizard).
  • Format: json-formattedcritical.
  • Save As: Single File, name schema.json, Encoding: UTF-8.
Only json-formatted produces valid JSON for AI-SQL-Chat.
3. Upload the File

Open /schema-query.html, choose your schema.json, and click Upload. The SQL generator now knows your tables and columns.

We don't send or store business data — only metadata (names).

Other Engines (Short Queries)

► PostgreSQL

Using information_schema:

SELECT
  table_name   AS table_name,
  column_name  AS column_name,
  data_type    AS data_type,
  is_nullable
FROM information_schema.columns
WHERE table_schema = 'public'       -- <-- replace
ORDER BY table_name, ordinal_position;
► SQL Server

Azure SQL / MS SQL:

SELECT
  TABLE_SCHEMA,
  TABLE_NAME,
  COLUMN_NAME,
  DATA_TYPE,
  IS_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS
-- optional filter:
-- WHERE TABLE_CATALOG = 'YourDB' AND TABLE_SCHEMA = 'dbo'
ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION;
► Oracle (short)

Your tables:

SELECT
  TABLE_NAME,
  COLUMN_NAME,
  DATA_TYPE,
  DATA_LENGTH,
  DATA_PRECISION,
  DATA_SCALE,
  NULLABLE
FROM USER_TAB_COLUMNS
ORDER BY TABLE_NAME, COLUMN_ID;

For a specific OWNER:

SELECT
  OWNER,
  TABLE_NAME,
  COLUMN_NAME,
  DATA_TYPE,
  DATA_LENGTH,
  DATA_PRECISION,
  DATA_SCALE,
  NULLABLE
FROM ALL_TAB_COLUMNS
WHERE OWNER = 'HR'  -- <-- REPLACE
ORDER BY TABLE_NAME, COLUMN_ID;

Already have your schema.json?

Upload schema and generate SQL Back to homepage