Request a demo

BigQuery · JSON function

BigQuery JSON_REMOVE

JSON_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. Paths that don't exist are ignored. Use it to strip personal data or bulky debug fields from JSON columns.

GoogleSQL for BigQuery · Checked against the official reference in November 2026

JSON_REMOVE deletes whole subtrees: removing $.user.email drops that key and its value, and removing $.debug drops the entire debug object. Paths run left to right, each on the result of the previous removal, which matters for arrays: after removing $[0], the next element moves to index 0.

Removal doesn't fail on missing data. A path that doesn't exist, or that runs into a value of the wrong type, is skipped, and a NULL path is ignored. Containers that become empty stay as {} or []. The errors are an invalid JSONPath and the root itself: '$' fails with "The JSONPath cannot be '$'".

Like JSON_SET, it works only on the JSON type, takes constant paths, and doesn't modify a table on its own: use it in a SELECT, a view or an UPDATE. Setting a key to NULL with JSON_SET keeps the key with a JSON null; JSON_REMOVE deletes it.

Syntax

JSON_REMOVE(json_expr, json_path[, ...])

Arguments and return value

ArgumentDescription
json_exprThe JSON value to modify. STRING input is not accepted.
json_pathOne or more constant JSONPaths to delete. $ is not allowed.

Returns: JSON. NULL if json_expr is NULL.

Examples

Redact personal fields

SELECT JSON_REMOVE(
  JSON '{"user": {"id": 42, "email": "ana@acme.io", "phone": "+420 777 000 000"}, "event": "signup"}',
  '$.user.email',
  '$.user.phone'
) AS redacted;
Result
redacted
{"event":"signup","user":{"id":42}}

Index shifting, empty containers and missing paths

After the first $[0] removes a, b moves to index 0 and is removed by the second.

SELECT
  JSON_REMOVE(JSON '["a", "b", "c"]', '$[0]', '$[0]') AS removed_twice,
  JSON_REMOVE(JSON '{"a": {"b": 1}}', '$.a.b') AS empty_object_kept,
  JSON_REMOVE(JSON '{"a": 1}', '$.missing') AS missing_path_ignored;
Result
removed_twiceempty_object_keptmissing_path_ignored
["c"]{"a":{}}{"a":1}

Share events without PII through a view

CREATE OR REPLACE VIEW `project.dataset.events_shared` AS
SELECT
  event_id,
  event_time,
  JSON_REMOVE(payload, '$.user.email', '$.user.phone', '$.debug') AS payload
FROM `project.dataset.events`;

Common mistakes

  • Removing several array elements by their original indexes. JSON_REMOVE(arr, '$[0]', '$[1]') removes the first and the third original elements, because indexes shift after each removal. List paths from the highest index down.
  • Trusting a redaction without checking it. A misspelled path is ignored silently, so the field you meant to remove stays; verify with JSON_KEYS on a sample.
  • Passing '$' to clear the whole value. It raises an error; select JSON '{}' instead.
  • Using it on a STRING column. Parse the column with PARSE_JSON first.

FAQ

How do I remove a key from a JSON column in BigQuery?

JSON_REMOVE(payload, '$.key') in a SELECT, or UPDATE t SET payload = JSON_REMOVE(payload, '$.key') WHERE ... to change stored rows.

How do I remove an element from a JSON array?

Use its index: JSON_REMOVE(payload, '$.items[2]'). For several elements, list the paths from the highest index down, since the remaining elements shift left.

What is the difference between JSON_REMOVE and setting a key to null?

JSON_REMOVE deletes the key. JSON_SET(payload, '$.key', NULL) keeps the key and gives it a JSON null value.

More JSON functions

All BigQuery JSON functions · All functions · BigQuery error messages

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.