Skip to content
cosmodev ~/tools/json-to-sql

JSON naar SQL INSERT

Data & DevOps

Converteer een JSON-array van objecten naar SQL INSERT-statements. Escapet strings correct en verwerkt nulls, booleans, getallen, geneste objecten en multi-row inserts.

Dialect

(Documentatie in het Engels)

What it does

Convert a JSON array of objects into SQL INSERT statements. Columns are the union of keys across all rows; values are escaped per dialect: strings double their single quotes ('O''Brien'), MySQL additionally escapes backslashes, MySQL renders booleans as 1/0, null stays NULL, numbers stay bare, and nested objects/arrays serialize to JSON text. Identifier quoting follows the dialect: double quotes for standard SQL and Postgres, backticks for MySQL. 100% client-side.

How to use it

  1. Paste a JSON array of objects (or a single object) into JSON — a sample is prefilled.
  2. Set the Table name and pick a Dialect: SQL, MySQL, or Postgres.
  3. The INSERTs render live on the right with the row count in the header.
  4. Copy them, or Download as insert.sql.

Examples

Basic insert with escaping — [{"id":1,"name":"O'Brien"}], table users →

INSERT INTO "users" ("id", "name") VALUES
  (1, 'O''Brien');

Mixed value types — [{"id":2,"ok":false,"note":null,"meta":{"a":1}}] →

INSERT INTO "users" ("id", "ok", "note", "meta") VALUES
  (2, FALSE, NULL, '{"a":1}');

MySQL dialect — same input renders INSERT INTO `users` (`id`, `ok`) VALUES (2, 0); (backtick identifiers, boolean as 0/1).

Missing keys across rows — a row without a column the other rows have gets NULL in that position.

Good to know

  • Private: conversion is local — nothing leaves the browser.
  • One multi-row INSERT ... VALUES (...), (...) statement per conversion, not one statement per row.
  • Postgres output also works for SQLite in most cases; pick SQL for the conservative baseline.
  • Related tools: JSON Formatter, JSON to TypeScript.
Broncode14 talen

100% client-side · je gegevens verlaten je browser nooit. Handig gevonden? Deel hem met een collega.