The length (amount of data to be pushed into the stack) typically comes directly after the OP_ code.
If the byte after OP_RETURN (0x6A
) is between 0x01
and 0x4B
, that is signaling the amount of data to push into the stack. This is defined in the Script language; a chart can be found here.

For example:
6A24AA21A9EDA45B20BAE4C0D9C747D7C17074D0606AF70FABA1394FC75E5DA6ABDA0426232E
The first byte 0x6A
decodes to OP_RETURN
and the next byte is 0x24
signaling
to push 36 bytes of data to the stack. (0x24
hexadecimal is 36 in decimal)
Our example therefore decodes to:
OP_RETURN PUSHDATA(36) AA21A9EDA45B20BAE4C0D9C747D7C17074D0606AF70FABA1394FC75E5DA6ABDA0426232E
If there was any more data after the 36 bytes it would be interpreted in coordination with the proper OP_code.