Request a demo

BigQuery reference

BigQuery JSON functions

BigQuery reads JSON stored as STRING or as the native JSON type. JSON_VALUE and JSON_QUERY are the standard way to extract values; the older JSON_EXTRACT family still works but treats paths differently.

Functions in this category

FunctionWhat it does
JSON_EXTRACTJSON_EXTRACT(json, json_path) returns the JSON at a path (an object, an array or a quoted string) as JSON-formatted text, or as JSON for JSON input.
JSON_EXTRACT_ARRAYJSON_EXTRACT_ARRAY(json[, json_path]) converts a JSON array into a SQL ARRAY with one element per item, as JSON-formatted strings (or JSON values for JSON input), ready for UNNEST.
JSON_EXTRACT_SCALARJSON_EXTRACT_SCALAR(json, json_path) returns a scalar JSON value (string, number or boolean) as a SQL STRING without quotes, and NULL for objects, arrays and JSON null.
JSON_KEYSJSON_KEYS(json[, max_depth][, mode => ...]) returns the unique keys of a JSON value as a sorted ARRAY<STRING>, with nested keys as dotted paths such as user.id.
JSON_QUERYJSON_QUERY(json, json_path) returns the JSON value at a path (object, array or scalar) as JSON text for STRING input or as JSON for JSON input, keeping quotes on strings.
JSON_QUERY_ARRAYJSON_QUERY_ARRAY(json[, json_path]) turns a JSON array into a SQL ARRAY with one element per item: ARRAY<JSON> for JSON input, JSON-formatted strings for STRING input.
JSON_REMOVEJSON_REMOVE(json, path[, path ...]) returns a copy of a JSON value with the data at each JSONPath removed, whether an object key or an array element.
JSON_SETJSON_SET(json, path, value[, path, value ...]) returns a copy of a JSON value with values inserted or replaced at the given JSONPaths, creating missing parents along the way.
JSON_TYPEJSON_TYPE(json) returns the type of a JSON value as a string: object, array, string, number, boolean or null.
JSON_VALUEJSON_VALUE(json[, json_path]) extracts a scalar (string, number or boolean) from JSON and returns it as a SQL STRING without quotes; objects, arrays and JSON null return NULL.
JSON_VALUE_ARRAYJSON_VALUE_ARRAY(json[, json_path]) extracts a JSON array of scalars as an ARRAY<STRING> with the quotes removed.
PARSE_JSONPARSE_JSON(json_string) converts JSON-formatted text into a value of the JSON type, validating it on the way.
TO_JSONTO_JSON(value) converts a SQL value (scalar, struct, array or whole row) into a value of the JSON type.
TO_JSON_STRINGTO_JSON_STRING(value[, pretty_print]) serializes any SQL value, from a scalar to a struct, an array or a whole row, into JSON text.

More of the BigQuery reference

Observability for every BigQuery table, in about 15 minutes

Masthead detects freshness, volume and schema anomalies, monitors pipeline errors and maps column-level lineage across all your projects, from logs and metadata only.