JSON To SQL

Login

Email
Password

Don't have an account yet?

Go to Sign up

Input Data
Sample {{ showCoderInput ? 'Choose File' : 'Enter Data' }}

                                
Valid JSON Invalid JSON — Cannot convert to JSON Array
Output Data
{{ copied ? 'Copied!' : 'Copy to Clipboard' }} Download File
Properties
Convert JSON to SQL online — paste, edit, and download SQL.

Database Type:
Select database type, affecting quote and data type syntax.
Table Name:
Primary Key:
Specify primary key field name for CREATE TABLE statement.
Output Options:
Create Table Batch Insert Drop Table (If Exists)
Convert Restart

JSON to SQL — Free Online Converter for MySQL, PostgreSQL, SQLite, and SQL Server

What Is SQL?

SQL (Structured Query Language) is the standard language for managing and manipulating relational databases. Defined by ISO/IEC 9075, SQL supports data definition (CREATE TABLE, DROP TABLE), data manipulation (INSERT, UPDATE, DELETE), and data querying (SELECT).

Common SQL statement types used in data migration:

StatementPurpose
CREATE TABLEDefine a new table with columns, data types, and constraints
INSERT INTOAdd rows of data into an existing table
DROP TABLEDelete a table and all its data
DROP TABLE IF EXISTSDelete a table only if it already exists (safe re-runs)

What Is JSON?

JSON (JavaScript Object Notation) is a lightweight data-interchange format defined by RFC 8259. It represents structured data as arrays and key-value objects. REST APIs, NoSQL databases, configuration files, and data export tools commonly output JSON.

Why Convert JSON to SQL?

ScenarioBenefit
Data migrationMove data from NoSQL/JSON-based systems into relational databases
API to databaseTransform API JSON responses into SQL INSERT statements
Database seedingPopulate development or test databases from JSON fixtures
Data importLoad JSON exports (from MongoDB, Firebase, etc.) into MySQL or PostgreSQL
ETL pipelinesConvert JSON intermediate format into SQL for warehouse loading
Backup restorationReconstruct database tables from JSON backups

Manually writing SQL INSERT statements from JSON data is error-prone, especially with many rows, nested structures, or database-specific quoting rules. This tool automates the conversion instantly.

Supported Database Types

MySQL

DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
 `id` INT,
 `name` VARCHAR(255),
 `email` VARCHAR(255),
 PRIMARY KEY (`id`)
);

INSERT
INTO `users` (`id`, `name`, `email`) VALUES (1, 'Alice', '[email protected]');
INSERT INTO `users` (`id`, `name`, `email`) VALUES (2, 'Bob', '[email protected]');

  • Uses backtick (`) quoting for identifiers

  • String values wrapped in single quotes (')

  • Supports DROP TABLE IF EXISTS

PostgreSQL

DROP TABLE IF EXISTS "users";
CREATE TABLE "users" (
 "id" INTEGER,
 "name" VARCHAR(255),
 "email" VARCHAR(255),
 PRIMARY KEY ("id")
);

INSERT
INTO "users" ("id", "name", "email") VALUES (1, 'Alice', '[email protected]');
INSERT INTO "users" ("id", "name", "email") VALUES (2, 'Bob', '[email protected]');

  • Uses double-quote (") quoting for identifiers

  • INTEGER instead of INT

  • Supports DROP TABLE IF EXISTS

SQLite

DROP TABLE IF EXISTS "users";
CREATE TABLE "users" (
 "id" INTEGER,
 "name" TEXT,
 "email" TEXT,
 PRIMARY KEY ("id")
);

INSERT
INTO "users" ("id", "name", "email") VALUES (1, 'Alice', '[email protected]');
INSERT INTO "users" ("id", "name", "email") VALUES (2, 'Bob', '[email protected]');

  • Uses TEXT instead of VARCHAR(255) for string columns

  • Compatible with PostgreSQL quoting style

  • Supports DROP TABLE IF EXISTS

SQL Server (T-SQL)

IF OBJECT_ID('users', 'U') IS NOT NULL DROP TABLE "users";
CREATE TABLE "users" (
 "id" INT,
 "name" NVARCHAR(255),
 "email" NVARCHAR(255),
 PRIMARY KEY ("id")
);
INSERT INTO "users" ("id", "name", "email") VALUES (1, N'Alice', N'[email protected]');
INSERT INTO "users" ("id", "name", "email") VALUES (2, N'Bob', N'[email protected]');

  • Uses NVARCHAR for Unicode string support

  • String values prefixed with N for Unicode literals

  • IF OBJECT_ID(...) IS NOT NULL DROP TABLE instead of DROP TABLE IF EXISTS

Core Features

1. Dual Input Modes

  • File Upload: Drag and drop or select a .json file.

  • Code Editor: Paste or type raw JSON with syntax highlighting and real-time validation.

2. Database Type Selection

Choose the target database to generate syntax-compatible SQL:

DatabaseIdentifier QuoteString TypeUnicode Prefix
MySQLBacktick `VARCHAR(255)No
PostgreSQLDouble quote "VARCHAR(255)No
SQLiteDouble quote "TEXTNo
SQL ServerDouble quote "NVARCHAR(255)N'...'

3. Table Name

Specify a custom table name for all generated SQL statements. Defaults to my_table if left empty.

4. Primary Key

Enter a field name to designate as the primary key. The tool adds a PRIMARY KEY (column) constraint to the CREATE TABLE statement. The specified column must exist in your JSON data.

5. Output Options

OptionWhat It Does
Create TableGenerates a CREATE TABLE statement with column names inferred from JSON keys and data types inferred from JSON values
Batch InsertCombines multiple INSERT INTO statements into a single INSERT INTO ... VALUES (...), (...), (...) statement
Drop Table (If Exists)Prepends a DROP TABLE IF EXISTS (or equivalent) statement before CREATE TABLE for safe re-runs

6. Automatic Data Type Inference

The tool inspects JSON values and maps them to appropriate SQL data types:

JSON Value TypeSQL Data Type
StringVARCHAR(255) / TEXT / NVARCHAR(255)
IntegerINT / INTEGER
FloatFLOAT / REAL
BooleanBOOLEAN / TINYINT(1)
nullTEXT (generic fallback)

7. Privacy by Design

All processing runs entirely in your browser. No data is uploaded to any server. The tool works offline after the initial page load.

How to Use This JSON to SQL Converter?

Step 1: Provide Your JSON Data

Choose one of two input methods:

  • Upload a file: Click "Choose File" and select a .json file, or drag it into the upload area.

  • Paste data: Click "Enter Data" to switch to the code editor. Paste your JSON array. The editor validates syntax in real time.

Step 2: Configure SQL Output

Use the Properties panel on the right:

  1. Database Type: Select MySQL, PostgreSQL, SQLite, or SQL Server.

  2. Table Name: Enter your target table name (e.g., users, orders, products).

  3. Primary Key: Enter the field name to use as primary key (e.g., id).

  4. Output Options: Check/uncheck Create Table, Batch Insert, and Drop Table as needed.

Step 3: Convert

Click Convert. The generated SQL appears in the "Output Data" panel.

Step 4: Copy or Download

  • Click Copy to Clipboard to paste the SQL into your database client or migration script.

  • Premium users can click Download File to save as a .sql file.

Complete Examples

Normal Example

Input JSON:

[
 {"id": 1, "name": "Alice", "email": "[email protected]", "active": true},
 {"id": 2, "name": "Bob", "email": "[email protected]", "active": false},
 {"id": 3, "name": "Carol", "email": "[email protected]", "active": true}
]

Configuration:

  • Database: MySQL

  • Table Name: users

  • Primary Key: id

  • Options: Create Table ✓, Batch Insert ✓, Drop Table ✓

Output:

DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
 `id` INT,  `name` VARCHAR(255),
 `email` VARCHAR(255),
 `active` TINYINT(1),
 PRIMARY KEY (`id`)
);

INSERT
INTO `users` (`id`, `name`, `email`, `active`) VALUES
 (1, 'Alice', '[email protected]', 1),
 (2, 'Bob', '[email protected]', 0),
 (3, 'Carol', '[email protected]', 1);

Example — PostgreSQL with Individual Inserts (No Batch)

Configuration:

  • Database: PostgreSQL

  • Table Name: users

  • Primary Key: id

  • Options: Create Table ✓, Batch Insert ✗, Drop Table ✓

Output:

DROP TABLE IF EXISTS "users";
CREATE TABLE "users" (
 "id" INTEGER,
 "name" VARCHAR(255),
 "email" VARCHAR(255),
 "active" BOOLEAN,
 PRIMARY KEY ("id")
);

INSERT
INTO "users" ("id", "name", "email", "active") VALUES (1, 'Alice', '[email protected]', true);
INSERT INTO "users" ("id", "name", "email", "active") VALUES (2, 'Bob', '[email protected]', false);
INSERT INTO "users" ("id", "name", "email", "active") VALUES (3, 'Carol', '[email protected]', true);

Example — Insert Only (No CREATE TABLE)

Configuration:

  • Database: SQLite

  • Table Name: users

  • Options: Create Table ✗, Batch Insert ✓, Drop Table ✗

Output:

INSERT INTO "users" ("id", "name", "email", "active") VALUES
 (1, 'Alice', '[email protected]', 1),
 (2, 'Bob', '[email protected]', 0),
 (3, 'Carol', '[email protected]', 1);

Supported JSON Input Formats

  • JSON arrays of objects (most common): [{"key": "value"}, ...]

  • JSON arrays of arrays: [["val1", "val2"], ...]

  • Nested JSON objects: Flattened to dot-notation keys automatically

Data Type Mapping Reference

MySQL

JSON TypeSQL Type
StringVARCHAR(255)
IntegerINT
FloatFLOAT
BooleanTINYINT(1)
nullTEXT

PostgreSQL

JSON TypeSQL Type
StringVARCHAR(255)
IntegerINTEGER
FloatREAL
BooleanBOOLEAN
nullTEXT

SQLite

JSON TypeSQL Type
StringTEXT
IntegerINTEGER
FloatREAL
BooleanINTEGER
nullTEXT

SQL Server

JSON TypeSQL Type
StringNVARCHAR(255)
IntegerINT
FloatFLOAT
BooleanBIT
nullNVARCHAR(255)

Frequently Asked Questions (FAQ)

  • Does the tool upload my data?

    No. All conversion happens locally in your browser using JavaScript. Your data never leaves your device.

  • Which databases are supported?

    MySQL, PostgreSQL, SQLite, and SQL Server (T-SQL). Select the target database to generate compatible SQL syntax.

  • What is the difference between Batch Insert and individual INSERT statements?

    Batch Insert combines all rows into a single INSERT INTO ... VALUES (...), (...), (...) statement. Individual inserts generate one INSERT INTO statement per row. Batch inserts are faster for large datasets. Individual inserts are easier to debug and partially execute.

  • How does the tool determine SQL data types?

    It infers types from the JSON values in your data. Strings become VARCHAR(255) (or TEXT for SQLite), integers become INT, floats become FLOAT, booleans become TINYINT(1) (MySQL), BOOLEAN (PostgreSQL), or BIT (SQL Server).

  • Can I specify a primary key?

    Yes. Enter the field name in the "Primary Key" input. The tool adds a PRIMARY KEY (column) constraint to the CREATE TABLE statement.

  • What does "Drop Table (If Exists)" do?

    It prepends a DROP TABLE IF EXISTS statement (or IF OBJECT_ID(...) IS NOT NULL DROP TABLE for SQL Server) before the CREATE TABLE. This makes the SQL script safe to re-run without errors.

  • Can I convert JSON to MySQL INSERT statements?

    Yes. Select "MySQL" as the database type. The tool generates MySQL-compatible syntax with backtick quoting and MySQL-specific data types.

  • Can I convert JSON to PostgreSQL?

    Yes. Select "PostgreSQL" as the database type. The tool generates PostgreSQL-compatible syntax with double-quote identifiers, INTEGER types, and BOOLEAN support.

  • Is there a file size limit?

    The tool processes data entirely in your browser. Files up to 10 MB typically convert without issues on modern hardware.

  • Can I use this on mobile?

    Yes. The tool is responsive and works on smartphones and tablets.

Featured Tools

Featured tools that you might find useful.

Popular Tools

List of popular tools that users love and frequently use.

New Tools

The latest tools added to our collection, designed for you.

Topics

The tools grouped by topics to quickly find what you need.
Free online Excel to JSON converter. Transform XLSX, XLS, XLSM files into JSON arrays, objects, or keyed formats instantly in your browser — no upload, 100% private.

Excel To JSON

Free online Excel to JSON converter. Transform XLSX, XLS, XLSM files into JSON arrays, objects, or keyed formats instantly in your browser — no upload, 100% private.
Free Excel to CSV converter. Convert XLSX, XLS, XLSM to CSV instantly in your browser. No upload, 100% private. Edit, transpose, deduplicate before exporting.

Excel To CSV

Free Excel to CSV converter. Convert XLSX, XLS, XLSM to CSV instantly in your browser. No upload, 100% private. Edit, transpose, deduplicate before exporting.
Free online Excel to SQL converter. Generate CREATE TABLE and INSERT statements from spreadsheets for MySQL, PostgreSQL, SQLite, and SQL Server. Supports batch insert, primary keys, and type inference.

Excel To SQL

Free online Excel to SQL converter. Generate CREATE TABLE and INSERT statements from spreadsheets for MySQL, PostgreSQL, SQLite, and SQL Server. Supports batch insert, primary keys, and type inference.
Free online Excel to ASCII table converter with 10 border styles (MySQL, Unicode, reStructuredText, and more). Add code comment wrappers in 8 languages. Supports text alignment. Client-side processing.

Excel To ASCII Table

Free online Excel to ASCII table converter with 10 border styles (MySQL, Unicode, reStructuredText, and more). Add code comment wrappers in 8 languages. Supports text alignment. Client-side processing.