> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for JSON_VALUE function

# JSON_VALUE

Takes a JSON document and extracts a JSON scalar value to SQL `TEXT` value.
For JSON strings, removes the outermost quotes and unescapes the values.
Other JSON scalars are not changed.
Returns a SQL `NULL` if a non-scalar value is given.

For `TEXT` input, this function pairs with the [JSON\_EXTRACT](/reference-sql/functions-reference/json/json-extract) function, which doesn't convert the JSON values to SQL values.

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
JSON_VALUE(<json>)
```

## Parameters

| Parameter | Description        | Supported input types |
| :-------- | :----------------- | :-------------------- |
| `<json>`  | The JSON document. | `JSON` or `TEXT`      |

## Return Type

`TEXT`

* If any of the input is `NULL` the output is `NULL` (propagates nulls).

## Examples

For the JSON document used in the examples below, see [JSON common example](/reference-sql/functions-reference/json#json-common-example).
**Example**

The following example returns `987654` (unquoted) from `JSON_VALUE` and `"987654"` (with quotes) from `JSON_POINTER_EXTRACT`:

<div className="query-window">
  ```
  SELECT JSON_VALUE(JSON_POINTER_EXTRACT('{"key":123,"value":{"uid":"987654"}}', '/value/uid')), JSON_POINTER_EXTRACT('{"key":123,"value":{"uid":"987654"}}', '/value/uid');
  ```

  | json\_value <span>text null</span> | json\_pointer\_extract <span>text null</span> |
  | :--------------------------------- | :-------------------------------------------- |
  | 987654                             | "987654"                                      |

  <p><span>Rows: 1</span><span>Execution time: 7.72ms</span></p>
</div>

**Example**

The following example casts the extracted value to `INT`:

<div className="query-window">
  ```
  SELECT JSON_VALUE(JSON_POINTER_EXTRACT('{"key":123,"value":{"uid":"987654"}}', '/key'))::INT;
  ```

  | json\_value <span>int null</span> |
  | :-------------------------------- |
  | 123                               |

  <p><span>Rows: 1</span><span>Execution time: 5.22ms</span></p>
</div>

**Example**

The following example returns `NULL` because `/value/keywords` contains a JSON array, not a scalar:

<div className="query-window">
  ```
  SELECT JSON_VALUE(JSON_POINTER_EXTRACT('{"value":{"keywords":["insanely","fast","analytics"]}}', '/value/keywords'));
  ```

  | json\_value <span>text null</span> |
  | :--------------------------------- |
  | NULL                               |

  <p><span>Rows: 1</span><span>Execution time: 5.47ms</span></p>
</div>

**Example**

The following example returns `NULL` for a `NULL` input:

<div className="query-window">
  ```
  SELECT JSON_VALUE(NULL);
  ```

  | json\_value <span>text null</span> |
  | :--------------------------------- |
  | NULL                               |

  <p><span>Rows: 1</span><span>Execution time: 6.12ms</span></p>
</div>
