Specifications

GROQ data types

Data types supported by GROQ

New to GROQ?

If you are just getting started with GROQ, check out the getting started guide first.

GROQ is strongly typed, meaning there is no implicit type conversion. Type conflicts (for example, 1 + "a") yield null.

For more information on how to express literal values for various data types, see the Syntax section.

Basic data types

Boolean

Logical truth values: true and false.

Float

Signed 64-bit double-precision floating-point numbers, for example, 3.14, using the IEEE 754 binary64 format. These have a magnitude of roughly 10⁻³⁰⁷ to 10³⁰⁸ and can represent 15 significant figures with exact precision. Beyond this, significant figures are rounded to 53-bit precision. The special IEEE 754 values of infinity and NaN (not a number) are not supported and are coerced to null.

Integer

Signed 64-bit integers, for example, 42, with a range of -2⁶³ to 2⁶³-1.

Null

An unknown value expressed as null. This is the SQL definition of null, which differs from the typical definition of "no value" in programming languages, and implies, among other things, that 1 + null yields null (1 plus an unknown number yields an unknown number). See the Operators section for further implications of this.

String

A UTF-8 encoded string of characters, for example, "Hi! 👋". The maximum string length is undefined but is fundamentally limited by the maximum document size and maximum HTTP request size as listed in Technical limits.

Composite data types

Array

An ordered collection of values, for example, [1, 2, 3]. Can contain any combination of other types, including other arrays.

Object

An unordered collection of key/value pairs (referred to as attributes) with unique keys, for example, {"a": 1, "b": 2}. Keys must be strings, while values can be any combination of other types, including other objects. If duplicate keys are specified, the last key is used.

Pair

A pair of values, for example, "a" => 1. Pairs can contain any combination of other types, including other pairs, and are mainly used internally with select(). In returned JSON, pairs are represented as arrays with two values.

Range

An interval containing all values ordered between the start and end values (for details on ordering, see "Comparison operators" in the Operators section). The starting value is always included, while the end may be either included or excluded. A right-inclusive range is expressed as two values separated by ... For example, 1..3 includes 1, 3, and every value between them, such as 1.5. A right-exclusive range is separated by .... For example, 1...3 includes every value from 1 up to, but not including, 3.

Ranges can have endpoints of any comparable data type (boolean, number, string, or datetime), but both endpoints must be of the same type (except integers and floats, which can be used interchangeably). Ranges with incompatible or invalid endpoint types yield null.

Known issue

Ranges are mainly used internally, for example, with the in operator and the array slice access operator. The endpoints can have context-dependent semantics. For example, in an array slice the range [2..-1] covers the range from the third array element to the last element, while the same range is considered empty when used with in. For more details, see the documentation for the relevant operators.

Subtypes

Subtypes are subsets of basic or composite types. Operators and functions that can act on the supertype can always act on the subtype as well, but the behavior may be modified, and some operators and functions can only act on the subtype.

Datetime

Datetimes are strings with ISO 8601-formatted date/time combinations, for example, 2018-11-04T13:45:21Z.

Known issue

Document

Documents are objects that contain the following special attributes (in addition to other arbitrary attributes):

  • _id (path, required): The unique ID of the document. IDs must begin with the characters a-zA-Z0-9_, followed by any of the characters a-zA-Z0-9_.-, and end with a-zA-Z0-9_-. IDs can have a maximum length of 128 characters and may not contain more than a single consecutive . character.
  • _type (string, required): An arbitrary document type. Types may not be longer than 255 characters, may not contain , or #, and may not begin with . or _.
  • _rev (string): A randomly generated revision ID corresponding to the transaction ID which generated this revision.
  • _createdAt (datetime): The time when the document was created.
  • _updatedAt (datetime): The time when the document was last modified.

Path

Paths are strings that represent a node or branch in a tree (that is, a hierarchy). They are typically used for document IDs, where each path segment is separated by ., for example, articles.business.finance.4861.

Paths can also be glob patterns, using * wildcards that don't cross . and ** wildcards that do cross .. For example, the path articles.business.finance.4861 is matched by the path articles.business.**, but not articles.business.*.

Paths are most commonly used with the in operator when filtering documents, for example, _id in path("articles.business.**").

Reference

References are objects that represent a reference to a different document. They have the following special attributes (in addition to other arbitrary attributes):

  • _ref (path, required): The ID of the referenced document.
  • _weak (boolean): If true, referential integrity is not enforced, that is, the reference is allowed to point to a non-existent document. Defaults to false.

Was this page helpful?

Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change site theme