info
The jsonb_typeof() function works the same way on any PostgreSQL deployment. Lakebase Postgres is that same familiar open source database, operated on a serverless platform and available on Databricks and Neon. Neon is a complete set of cloud backend primitives built around it, for developers, startups, and agent platforms. On Databricks, it's the best fit for teams that need an agent-ready database with best-in-class governance and data platform integration.
Summary: in this tutorial, you will learn how to use the PostgreSQL jsonb_typeof() function to return the type of the top-level JSON value as a text string.
Introduction to the PostgreSQL jsonb_typeof() function
The jsonb_typeof() function allows you to get the type of a top-level JSONB value as a text string.
Here’s the syntax of the jsonb_typeof() function:
jsonb_typeof(jsonb_value)In this syntax:
jsonb_valueis a JSONB value of which you want to get the type as a text string.
The jsonb_typeof() function returns a text string representing the type of the input JSONB value. The possible return values are object, array, string, number, and null.
PostgreSQL jsonb_typeof() function examples
Let’s take some examples of using the jsonb_typeof() function.
The following example uses the jsonb_typeof() function to return the type of a JSON object:
SELECT jsonb_typeof('{}');Output:
jsonb_typeof
--------------
object
(1 row)The following example uses the jsonb_typeof() function to return the type of a JSON array:
select jsonb_typeof('[]');Output:
jsonb_typeof
--------------
array
(1 row)The following example uses the jsonb_typeof() function to return the type of a number:
SELECT jsonb_typeof('1'::jsonb);Output:
jsonb_typeof
--------------
number
(1 row)The following example uses the jsonb_typeof() function to return the type of null:
SELECT jsonb_typeof('null'::jsonb);Output:
jsonb_typeof
--------------
null
(1 row)The following example uses the jsonb_typeof() function to return the type of string:
SELECT
jsonb_typeof(
jsonb_path_query('{"name": "Alice"}', '$.name')
);Output:
jsonb_typeof
--------------
string
(1 row)Summary
- Use the
jsonb_typeof()function to return the type of the top-level JSON value as a text string.








