Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

JSON_SIZE function

Focus mode
JSON_SIZE function - Amazon Redshift

The JSON_SIZE function returns the number of bytes in the given SUPER expression when serialized into a string.

Syntax

JSON_SIZE(super_expression)

Arguments

super_expression

A SUPER constant or expression.

Return type

INTEGER

The JSON_SIZE function returns an INTEGER indicating the number of bytes in the input string. This value is different from the number of characters. For example, the UTF-8 character ⬤, a black dot, is 3 bytes in size even though it is 1 character.

Usage notes

JSON_SIZE(x) is functionally identical to OCTET_LENGTH(JSON_SERIALIZE). However, note that JSON_SERIALIZE returns an error when the provided SUPER expression would exceed the VARCHAR limit of the system when serialized. JSON_SIZE does not have this limitation.

Examples

To return the length of a SUPER value serialized to a string, use the following example.

SELECT JSON_SIZE(JSON_PARSE('[10001,10002,"⬤"]')); +-----------+ | json_size | +-----------+ | 19 | +-----------+

Note that the provided SUPER expression is 17 characters long, but ⬤ is a 3-byte character, so JSON_SIZE returns 19.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.