Why JSON to CSV to SQL Loses Data Types
CSV can carry rows and columns, but it cannot carry JSON types. Learn what disappears during a two-step SQL conversion.
SQL statements will appear here..
The interesting part of converting JSON to SQL is not the syntax, it is the types. JSON has real booleans, real numbers and a real null; CSV has none of those, only text. That difference is why the JSON to CSV to SQL route quietly damages data, and why this page exists as its own tool rather than a link to the other two.
Each column is decided by the values actually present across every row. Integers stay integers; an integer column widens to a numeric one the moment a decimal appears; a boolean beside a number makes the column text, because no dialect stores both in one place. Nulls and missing keys are ignored while deciding, so they can never narrow a column to text.
The dialect choice changes two things and only two things. Identifier quoting: double quotes for PostgreSQL and SQLite, backticks for MySQL, with any quote character inside a name doubled so a hostile column name cannot break out. And the type names written into the CREATE TABLE — plus the booleans, since SQLite has no boolean literal and stores 1 and 0 instead.
Nested objects and arrays are written as JSON text rather than expanded into extra tables. That is a deliberate limit. Deciding that an array of objects should become a second table with a foreign key is schema design, and a converter that guessed at it would be wrong often enough to be worse than useless.
Most online JSON to SQL tools post your JSON to a server. An API payload usually carries exactly the fields you would not want on somebody else's disk — email addresses, tokens, customer names. This page generates the SQL in your browser, so the JSON never leaves the tab.
The other common workaround is a two-step trip through JSON to CSV and then CSV to SQL. It works for a flat array of strings and numbers, and it is the wrong tool the moment a value is a boolean, a null or a nested object, because CSV cannot carry any of those as anything but text.
Going the other direction, SQL to CSV reads rows back out of a dump, and SQL Formatter pretty-prints the statements once you have them.