Skip to content

stringifyConvexValue

stringifyConvexValue(props): string

Defined in: packages/core/src/utils/convexValueJson.ts:33

Display-only JSON serialization of a Convex value — never throws on a bigint (int64) or an ArrayBuffer (bytes), both of which make the native JSON.stringify throw.

bigint renders as bare decimal digits, unquoted ({"count": 9007199254740993}), so a reader sees the real integer rather than a string. ArrayBuffer renders as "<N bytes>" — the byte count, not the bytes themselves, matching the bytes() field’s own cell convention. Lossy and one-way: use serializeConvexValue/ parseConvexValue where a round trip is required.

The bigint marker embeds a fresh crypto.randomUUID() nonce on every call, so a string VALUE that happens to look like the marker (e.g. a text() field someone filled with "\u0000vex:bigint:5") can never collide with it and render unquoted — only a value this same call itself replaced can match the nonce it generated.

number

Passed through to JSON.stringify’s own space argument.

unknown

The value to serialize.

string

The serialized string.