Convert a Single JSON Object to INSERT
Convert a single JSON object (not wrapped in an array) into a SQL INSERT statement. The tool automatically wraps single objects into a one-row bulk format.
Detailed Explanation
Single Object Support
While the bulk INSERT tool is designed for arrays, it also handles single JSON objects gracefully. When you paste a lone object (not wrapped in [...]), the tool automatically wraps it in an array and generates a standard INSERT statement.
Example JSON
{
"product_id": "SKU-001",
"name": "Wireless Mouse",
"price": 29.99,
"in_stock": true,
"category": "Electronics"
}
Generated SQL
INSERT INTO products ("product_id", "name", "price", "in_stock", "category")
VALUES
('SKU-001', 'Wireless Mouse', 29.99, TRUE, 'Electronics');
When to Use Single Objects
This is handy when you are testing your INSERT logic with a single record before processing a larger dataset. The tool validates the object structure, infers column types, and lets you configure all the same options (dialect, quoting, NULL handling) as with multi-row inserts.
Auto-Detection
The tool detects whether your input is an array or an object:
| Input | Behavior |
|---|---|
[{...}, {...}] |
Multi-row INSERT |
{...} |
Single-row INSERT (auto-wrapped) |
[] |
Error: empty array |
| Non-object items | Error: invalid element |
This flexibility means you do not need to manually wrap your data in brackets.
Use Case
You are debugging a single record from an API response and want to quickly generate the INSERT statement to test it in your local development database before running a full import.