JSON_EXTRACT is a powerful custom function that extracts specific values from JSON strings in your spreadsheet. It can find both single values and nested data using simple key paths, making it easy to pull out the exact information you need from complex JSON structures.
=JSON_EXTRACT(jsonString, [field])
Parameter | Data Type | Required | Description |
---|---|---|---|
jsonString | string | Yes | The JSON string to parse and extract values from |
field | string | No | The key to extract or chain of keys separated by '<' (e.g., "city<address<person") |
To extract deeply nested values, use the '<' delimiter to specify a path:
"city<address<person"
=JSON_EXTRACT(A1, "city<address<person")
extracts the city from inside the address inside the person objectWhen a key appears multiple times in your JSON, JSON_EXTRACT finds all occurrences:
Extract a person's name from a JSON object:
=JSON_EXTRACT("{""person"":{""name"":""John"",""age"":30}}", "name")
["John"]
Extract the city from a nested address structure:
=JSON_EXTRACT("{""data"":{""address"":{""city"":""New York""}}}", "city<address<data")
["New York"]
Extract all project names from a JSON array:
=JSON_EXTRACT("{""projects"":[{""name"":""Project A""},{""name"":""Project B""}]}", "name")
["Project A", "Project B"]
Get the entire JSON structure (useful for debugging):
=JSON_EXTRACT("{""status"":""success"",""data"":{""count"":5}}")
Extract all prices from a complex API response:
=JSON_EXTRACT(URL_READER("https://api.example.com/data"), "price")
""
)key1<key2<key3
) for deeply nested valuesCause: The JSON string is not properly formatted or contains syntax errors.
Solution: Verify your JSON with a JSON validator. Common issues include missing quotes, unescaped special characters, or trailing commas.
Cause: The specified key does not exist in the JSON structure.
Solution: Check that your key name matches exactly (case-sensitive) and that the path is correct if using chained keys.
Cause: JSON_EXTRACT searches the entire JSON structure recursively.
Solution: For predictable ordering, structure your JSON appropriately or sort the results after extraction.
Cause: JSON_EXTRACT converts all values to strings for consistent output.
Solution: Use functions like VALUE() to convert numeric strings back to numbers if needed.
Cause: Key path order is reversed (right-to-left) in the chain expression.
Solution: For path "a.b.c", use "c<b<a" in the field parameter (reading from inner to outer).
Cause: When a key points to an object, the function returns the object's keys rather than the object itself.
Solution: Use a more specific path to target the exact value you need within the object.
Cause: Arrays are handled differently than objects.
Solution: Extract specific array elements by first extracting the array, then accessing elements with another function.
JSON_EXTRACT will search through arrays and return all matching keys it finds at any level. If the key directly references an array, the function will return the array contents as strings.
No, each JSON_EXTRACT call extracts a single field. To extract multiple fields, use multiple JSON_EXTRACT calls or consider using EXTRACT_JSON for tabular data.
All values are returned as strings. Use the VALUE() function to convert to numbers: =VALUE(JSON_EXTRACT(A1,"price"))
.
JSON_EXTRACT returns an array. If your formula is in a cell adjacent to empty cells, Google Sheets may spill the results across multiple cells. Ensure you have enough empty cells to display all results.
Use array indexing with INDEX: =INDEX(JSON_EXTRACT(A1,"name"),1)
returns only the first match.
Use JSON_EXTRACT to find the key across all levels. For specific array indexing, you may need to use a combination of functions or extract the array first.
The field parameter is case-sensitive and matches exactly. Special characters in key names are supported but must match exactly.
There's no specific depth limit for chained extraction, but very complex paths may impact performance. For extremely deep nesting, consider breaking extraction into multiple steps.
No, wildcard characters are not supported. Each key must match exactly.
Yes, the function works with any valid JSON string regardless of formatting.
1 week ago