JSON to OPENJSON Generator
Paste a sample JSON payload and get a SQL Server OPENJSON query with column types inferred from the data.
- Updated
- Markdown
Paste an API response, webhook body, or export file and get an OPENJSON ... WITH (...) query that turns it into rows. Everything runs in your browser; nothing is sent anywhere.
Notes
- Rows: if the JSON is wrapped, such as
{ "data": [ ... ] }, the first array of objects is used. Set the path yourself (for example$.result.items) to choose a different one. - Types are a starting point: they come from the sample only. A column that held small numbers in the sample may hold larger ones in production, so check sizes before relying on them.
- Dates: ISO 8601 strings become
DATE,DATETIME2, orDATETIMEOFFSET(when they includeZor an offset). - Nested data: objects are flattened into
parent_childcolumns. Arrays are returnedAS JSONso you can pass them to a secondOPENJSONcall withCROSS APPLY. - Case matters: JSON property names in the paths are case-sensitive. A path that does not match returns
NULLrather than an error. OPENJSONneeds SQL Server 2016+ with database compatibility level 130 or higher.
For loading the result into a staging table and validating it before it reaches anything downstream, see Designing Integration Pipelines That Fail Safely. For passing lists into queries, see Pass a List of IDs Without Dynamic SQL.
Was this useful?
Thanks. What was the problem?