Property Types
ObjectBox supports a variety of data types inside the stored objects including various list types and even special "flex" types for dynamic and schema-less data.
ObjectBox stores data as objects, which are instances of entity classes you define. Objects consist of properties, which are the individual fields that hold your data, like a user's name or age. This page covers the property types ObjectBox supports:
Standard types for single values of a fixed type
List/Vector types for collections of values of a fixed type
The flex type for dynamic and schema-less data
Standard Types
Standard types include boolean, integers, floating point types, string, and date types. These are the most common types you will use in typical applications.
Quick Reference
Boolean
Bool
1 byte
Integer (8-bit)
Byte
1 byte
Integer (16-bit)
Short
2 bytes
Integer (32-bit)
Int
4 bytes
Integer (64-bit)
Long
8 bytes
To-One Relation
Relation
8 bytes
Float (32-bit)
Float
4 bytes
Float (64-bit)
Double
8 bytes
Text Character
Char
2 bytes
String
String
UTF-8 bytes
Date (ms)
Date
8 bytes (long)
Date (ns)
DateNano
8 bytes (long)
Integers
ObjectBox supports all standard integer types, from 8-bit to 64-bit. Rule of thumb: use large enough integer types that are safe for your use case in the future. Use smaller types only if you are certain about the range of values as you cannot change the type of an existing property later.
Kotlin unsigned types (UByte, UShort, UInt, ULong) are also supported—they're stored as their signed equivalents.
Note: Dart just has int and does not differentiate between the integer types. You can still use ObjectBox types to pick the storage type and align with other languages (e.g. when using Sync).
Floating Point
Choose 32-bit floats for memory efficiency when ~7 digits of precision is enough. Use 64-bit doubles when you need ~15 digits.
Strings
Strings are stored as UTF-8 encoded bytes without a length limit.
Dates and Times
ObjectBox stores dates as 64-bit integers ("timestamps") representing time since the Unix epoch (January 1, 1970, 00:00:00 UTC). Choose your precision:
Milliseconds
Date (the default)
Most applications
Nanoseconds
DateNano
High-precision timestamps
Note: while DateNano values are always stored as nanoseconds, the actual precision of the values depends on the platform and programming language. For example, Dart uses only microsecond precision (the last three digits of the nanosecond are "truncated").
Proper UTC handling requires ObjectBox for Dart/Flutter 5.1 with the dateUtc and dateNanoUtc annotations. Prior versions do not support proper UTC handling. Please update and avoid the old date and dateNano annotations.
IDs and Relations
Every ObjectBox entity must have exactly one ID property of type Long (64-bit integer). See Entity Annotations for details.
"Relation" is used for one of two relation types available in ObjectBox. It's a 64-bit integer that references the ID of another object. Depending on the programming language you use, it may translate to a "to-one" construct. See Relations for complete documentation.
Lists and Arrays
Store collections of values directly; no special tables or joins required. The internal type names are "vectors", but they may translate to lists or arrays in the programming language you use.
Quick Reference
BoolVector
Bool values (stored using one byte per value)
ByteVector
Byte values (8-bit integers), binary data, BLOB
ShortVector
Short values (16-bit integers)
CharVector
Char values (16-bit characters)
IntVector
Int values (32-bit integers)
LongVector
Long values (64-bit integers)
FloatVector
Float values (32-bit floating point)
DoubleVector
Double values (64-bit floating point)
StringVector
String values (UTF-8 encoded strings)
DateVector
Date values (64-bit timestamp)
DateNanoVector
DateNano values (high precision 64-bit timestamp)
Language Examples
Flex Properties
Flex properties can hold data values of various types, including complex structures, in a single property. They serve two main purposes:
Dynamic data: you want to process JSON-like data dynamically
Nested objects: as an alternative to relations, you can embed map-like data directly
See FlexObjectConverter for Java/Kotlin additional notes.
See FlexObjectConverter for Java/Kotlin additional notes.
Custom Types
If the existing property types do not fully cover your use case, check custom types and converters.
Last updated
Was this helpful?