Convert NDJSON to SQL Online
Convert NDJSON files to SQL INSERT statements directly in your browser. Copy or download the generated SQL — no upload required.
About converting NDJSON to SQL
NDJSON to SQL gives you a runnable script from a stream sample: a CREATE TABLE for the keys found in the file and one INSERT per line. Typical uses are loading a slice of production events into a local database to reproduce a bug, building a test fixture from webhook payloads captured as JSON Lines, or sharing a small dataset with someone who only has a SQL client.
The script contains the first 1,000 lines. That is plenty for a fixture but not for a full log, and per-row INSERT statements are slow at volume anyway. For larger files, convert to CSV and use COPY in PostgreSQL, LOAD DATA in MySQL or .import in SQLite. The table takes its name from the file, so events.jsonl becomes a table named events.
Types reflect what the lines contained. Keys with consistent integers become BIGINT, decimals become DOUBLE PRECISION, and strings become TEXT, including ISO timestamps with milliseconds, which are not detected as dates. A key with mixed types across lines is typed TEXT, and its values keep their JSON quoting. Nested objects and arrays go into TEXT columns as JSON strings, which PostgreSQL can cast to jsonb.
Worked example
A small sample file, converted with the default settings.
Input (NDJSON)
{"ts":"2026-03-02T14:05:11.042Z","level":"info","service":"checkout","status":200,"latency_ms":41.7,"user_id":"u_1842"}
{"ts":"2026-03-02T14:05:12.310Z","level":"error","service":"checkout","status":502,"latency_ms":3012.4,"user_id":null}
{"ts":"2026-03-02T14:05:12.877Z","level":"info","service":"search","status":200,"latency_ms":12.9,"user_id":"u_0077"}
{"ts":"2026-03-02T14:05:14.105Z","level":"warn","service":"search","status":429,"latency_ms":0.8,"user_id":"u_1842"}Output (SQL)
CREATE TABLE IF NOT EXISTS "data" (
"ts" TEXT,
"level" TEXT,
"service" TEXT,
"status" BIGINT,
"latency_ms" DOUBLE PRECISION,
"user_id" TEXT
);
INSERT INTO "data" VALUES ('2026-03-02T14:05:11.042Z', 'info', 'checkout', 200, 41.7, 'u_1842');
INSERT INTO "data" VALUES ('2026-03-02T14:05:12.310Z', 'error', 'checkout', 502, 3012.4, NULL);
INSERT INTO "data" VALUES ('2026-03-02T14:05:12.877Z', 'info', 'search', 200, 12.9, 'u_0077');
INSERT INTO "data" VALUES ('2026-03-02T14:05:14.105Z', 'warn', 'search', 429, 0.8, 'u_1842');What changes when you convert NDJSON to SQL
- CREATE TABLE lists ts, level, service and user_id as TEXT, status as BIGINT and latency_ms as DOUBLE PRECISION.
- Every line of the file produces its own INSERT statement, in the same order as the log.
- Timestamps stay quoted strings such as '2026-03-02T14:05:11.042Z' in a TEXT column.
- The null user_id on the error line becomes the SQL keyword NULL.
- Identifiers use double quotes, which PostgreSQL and SQLite accept; MySQL needs ANSI_QUOTES mode or backticks.
Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.
Frequently Asked Questions
How do I get the timestamps into a TIMESTAMP column?
In PostgreSQL, run the script and then ALTER TABLE events ALTER COLUMN ts TYPE timestamptz USING ts::timestamptz. The Z suffix is read as UTC. In other databases, add a new column and fill it with that database's ISO 8601 parsing function.
Why does the script include only 1,000 lines?
SQL output is generated as text in your browser and is capped at the first 1,000 records. Use Filter or Sample NDJSON to choose which 1,000 you get, or convert to CSV for a bulk load of the whole file.
Can I load the script into SQLite?
Yes. SQLite accepts double-quoted identifiers and maps BIGINT, DOUBLE PRECISION and TEXT to its own storage classes. The lowercase true and false literals used for boolean keys work in SQLite 3.23 and later.
What is SQL format?
SQL (Structured Query Language) is the standard language for querying and manipulating relational databases. The output contains CREATE TABLE and INSERT INTO statements ready to run against any SQL-compatible database.
Related Tools
NDJSON Viewer Online
View and inspect NDJSON files directly in your browser. Browse rows, check column names and data types — no upload required, your data stays on your device.
Convert NDJSON to CSV Online
Convert NDJSON files to CSV format directly in your browser. No upload required — your data never leaves your device.
Convert NDJSON to Parquet Online
Convert NDJSON files to Parquet format directly in your browser. No upload required — your data never leaves your device.
Convert NDJSON to Excel Online
Convert NDJSON files to Excel format directly in your browser. No upload required — your data never leaves your device.
Convert NDJSON to JSON Online
Convert NDJSON files to JSON format directly in your browser. No upload required — your data never leaves your device.