Skip to content

JSON format choices ​

Choose a JSON format by its outer structure and whether values retain their JSON types or become strings.

Layouts ​

Format Shape
json_each_row One named object per row.
json_compact_each_row One positional array per row.
json_columns One object containing named column arrays.
json_compact_columns Positional column arrays.
json_strings_each_row Objects whose values are all JSON strings.
json_compact_strings_each_row Positional arrays whose values are all JSON strings.
json_compact_each_row_with_names_and_types Names and types header arrays followed by row arrays.
json_compact One output-only document with metadata and positional data.

The string-only variants also encode SQL NULL as the quoted marker "ᴺᵁᴸᴸ", rather than JSON null. Their input values must be JSON strings for known fields.

Column-oriented example ​

sql
SELECT 7 AS id, 'Ada' AS name
FORMAT json_columns;
text
{
    "id": [7],
    "name": ["Ada"]
}

Choose json_each_row for a simple row stream, or browse the format reference for every supported layout and its settings.