> ## 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_TYPEOF function

# JSON_TYPEOF

Returns the type of a JSON value as a string: `'null'`, `'boolean'`, `'number'`, `'string'`, `'array'`, or `'object'`.
Returns `NULL` if the input is `NULL`.

The argument may be either a native `JSON` value (which is inspected directly, without re-parsing) or a `TEXT` value containing a JSON document (which is parsed).

## Syntax

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

### Aliases

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

## Parameters

| Parameter | Description                            | Supported input types |
| :-------- | :------------------------------------- | :-------------------- |
| `<json>`  | The JSON value whose type is reported. | `JSON`, `TEXT`        |

## Return Type

The `JSON_TYPEOF` function returns a result of type `TEXT`.

## Remarks

When the argument is a native `JSON` value it is already validated, so the type is determined directly from the stored representation.
When the argument is `TEXT`, the input is parsed and an error is raised if it is not valid JSON.

## Examples

The following examples report the type of each native `JSON` value:

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
SELECT JSON_TYPEOF('{"a": 1}'::JSON);   -- Returns 'object'
SELECT JSON_TYPEOF('[1, 2, 3]'::JSON);  -- Returns 'array'
SELECT JSON_TYPEOF('"hello"'::JSON);    -- Returns 'string'
SELECT JSON_TYPEOF('42'::JSON);         -- Returns 'number'
SELECT JSON_TYPEOF('true'::JSON);       -- Returns 'boolean'
SELECT JSON_TYPEOF('null'::JSON);       -- Returns 'null'
```

The argument can also be a `TEXT` value containing a JSON document, which is parsed before its type is reported:

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
SELECT JSON_TYPEOF('[1, 2, 3]'::TEXT);  -- Returns 'array'
```
