PlayWithJSON

JSON to MySQL Converter

MySQL DDL & SQL

Convert any JSON or JSON5 dataset into MySQL CREATE TABLE statements and INSERT INTO queries instantly in your browser.

Samples:
Engine:
Indent:
JSON / JSON5 InputJSON
19 lines | 409 charsJSON
MySQL SQL OutputSQL
-- MySQL Table Schema generated from JSON
CREATE TABLE IF NOT EXISTS `users` (
  `status` VARCHAR(255) DEFAULT NULL,
  `statusCode` INT DEFAULT NULL,
  `data` JSON DEFAULT NULL,
  `timestamp` DATETIME DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Sample Data Insertion
INSERT INTO `users` (`status`, `statusCode`, `data`, `timestamp`) VALUES
('success', 200, '{"userId":"usr_948201a","username":"shyam_dev","email":"shyam@example.com","profile":{"firstName":"Shyam","lastName":"Bhati","skills":["Next.js","TypeScript","Tailwind CSS"]},"preferences":{"theme":"dark","notifications":true}}', '2026-10-20 21:10:00');
11 lines | 652 charsSQL

JSON to MySQL Table & INSERT SQL Generator Online

Quickly convert JSON objects or arrays of records into production-grade MySQL CREATE TABLE DDL scripts and parameterized INSERT INTO SQL statements.

Intelligently infers optimal column types including INT, BIGINT, DECIMAL, VARCHAR, TEXT, DATETIME, and native JSON columns with primary key auto-increment support. Everything runs completely in your browser.

{}

Why Use PlayWithJSON?

  • Generate standard MySQL CREATE TABLE statements with proper collations
  • Generate corresponding INSERT INTO data insertion queries
  • Automatic detection of PRIMARY KEY (AUTO_INCREMENT)
  • Native MySQL JSON column support for nested structures
  • Client-side execution keeping all database data confidential

Key Features of MySQL Table Generator

DDL & INSERT Generation

Generates both the schema structure and the SQL data insert statements in one step.

Smart Type Inference

Automatically detects integers, big numbers, decimals, timestamps, dates, and booleans.

MySQL JSON Columns

Nested JSON objects and arrays are automatically mapped to MySQL native JSON columns.

Configurable Table & Keys

Customize table name, primary key field, storage engine (InnoDB), and backtick quoting.

SQL Injection Safe Escaping

Values inside generated INSERT statements are properly escaped and formatted for MySQL.

Export to .sql File

Download the generated output directly as a .sql file or copy to clipboard for MySQL Workbench or phpMyAdmin.

How to Convert JSON to MySQL

1

Paste JSON / JSON5

Paste a JSON object, list of records, or an API response into the editor.

2

Set Table Name

Specify your target MySQL table name and designated primary key.

3

Toggle INSERTs

Choose whether you want schema only or schema plus INSERT queries.

4

Copy or Download

Copy the SQL or download it as a .sql script ready to execute.

JSON to MySQL Example

JSON (Input)
[ { "id": 1, "username": "shyam", "email": "shyam@example.com", "is_active": true, "preferences": { "newsletter": false }, "created_at": "2026-10-30T10:00:00Z" } ]
MySQL SQL (Output)
1-- MySQL Table Schema generated from JSON
2CREATE TABLE IF NOT EXISTS `users` (
3 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
4 `username` VARCHAR(255) DEFAULT NULL,
5 `email` VARCHAR(255) DEFAULT NULL,
6 `is_active` TINYINT(1) DEFAULT 0,
7 `preferences` JSON DEFAULT NULL,
8 `created_at` DATETIME DEFAULT NULL
9) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
10
11-- Sample Data Insertion
12INSERT INTO `users` (`id`, `username`, `email`, `is_active`, `preferences`, `created_at`) VALUES
13(1, 'shyam', 'shyam@example.com', 1, '{"newsletter":false}', '2026-10-30 10:00:00');

Input Validation Rules

Invalid Structure
1"just a string"
MySQL generation requires an object or array of objects representing database rows.
Valid Table Data
1[{ "id": 1, "status": "active" }]

Supported MySQL Features

INT and BIGINT auto-increment primary keys
VARCHAR(255) and TEXT column determination
TINYINT(1) for boolean flags
DATETIME, DATE, and TIME timestamp detection
Native MySQL JSON column data type
Configurable table name and primary key
InnoDB and MyISAM engine declarations
Safe string escaping for single quotes and backslashes
100% private in-browser code execution
Frequently Asked Questions

Frequently Asked Questions about JSON to MySQL

Nested objects and arrays are mapped to MySQL’s native `JSON` column type, allowing querying with `JSON_EXTRACT()` or the `->>` operator in MySQL 5.7+ and 8.0+.

More JSON Developer Tools

View All Tools

JSON Formatter

Format, validate and inspect JSON data

JSON5 Formatter

Format and validate JSON5 with comments

JSON ↔ JSON5

Convert between JSON and modern JSON5

JSON to TypeScript

Generate TypeScript interfaces from JSON

JSON to Zod

Generate Zod schemas from JSON

Text to JSON

Convert text and schemas into structured JSON

JSON Sorter Online

Sort JSON keys alphabetically and order arrays

JWT Decoder Online

Decode JWT header, payload and expiration

JSON Stringify Online

Escape quotes and stringify or unescape JSON

Mock JSON Generator

Generate realistic mock data for APIs and testing

JSON to CSV

Export structured JSON arrays into CSV spreadsheets

JSONPath Tester

Query and filter JSON data with path expressions

JSON Schema Generator

Generate JSON Schema from sample JSON

JSON Diff & Compare

Compare two JSON objects and find differences

JSON ↔ YAML

Convert JSON/JSON5 to YAML and back with comments

JSON ↔ XML

Convert JSON to XML and XML to JSON with attributes

YAML to CSV

Convert YAML lists and objects into spreadsheets

CSV to JSON / JSON5

Convert CSV/TSV to JSON or JSON5 with type parsing

JSON to BigQuery

Generate BigQuery Schema JSON and CREATE TABLE DDL

JSON to GraphQL

Generate GraphQL SDL types, queries, and inputs

JSON to MySQL

Generate MySQL CREATE TABLE DDL and INSERT queries

JSON to PostgreSQL

Generate PostgreSQL CREATE TABLE DDL, JSONB and INSERTs

JSON Flattener

Flatten nested JSON to dot notation or unflatten back

JSON Tree Visualizer

Interactive SVG mindmap graph and collapsible node tree

JSON Minifier Online

Compact and compress JSON by stripping whitespace

JSON Token Counter

Calculate LLM tokens (GPT-4o, Claude) and API costs

Broken JSON Repair

Automatically heal broken and truncated AI/LLM JSON