clickhouse-js-node-rowbinary
clickhouse/agent-skills
Generate TypeScript/JavaScript code to read and write ClickHouse RowBinary streams in Node.js.
What is clickhouse-js-node-rowbinary?
This skill generates encoders and decoders for ClickHouse's RowBinary wire format (RowBinary, RowBinaryWithNames, RowBinaryWithNamesAndTypes). Use it when you need to parse binary responses from ClickHouse or encode values into binary payloads for the HTTP server in Node.js environments.
- Generate readers that decode RowBinary bytes into JavaScript values
- Generate writers that encode JavaScript values into RowBinary bytes
- Support RowBinary, RowBinaryWithNames, and RowBinaryWithNamesAndTypes variants
- Inline per-type codec operations for straight-line performance without indirection
- Handle wide numerics (Int128/Int256/UInt128/UInt256, Decimal128/Decimal256) and binary types (IPv4, IPv6, UUID, FixedString)
- Provide per-type reference tables and streaming patterns for both directions
How to install clickhouse-js-node-rowbinary
npx skills add https://github.com/clickhouse/agent-skills --skill clickhouse-js-node-rowbinary- Node.js environment
- Knowledge of the ClickHouse schema and column types you intend to encode/decode
- Familiarity with DataView and little-endian byte ordering
How to use clickhouse-js-node-rowbinary
- 1.Determine whether you need a reader (decode RowBinary responses) or writer (encode values into RowBinary)
- 2.Consult reader.md for decoding guidance or writer.md for encoding guidance, depending on your use case
- 3.Review the per-type reference tables in the appropriate direction file for your ClickHouse data types
- 4.Generate or write TypeScript code using the provided per-type readX/writeX functions as a reference
- 5.Inline the leaf operations into your codec rather than calling them indirectly, and annotate each column with its ClickHouse type
- 6.Test correctness first, then optimize by monomorphizing generic types and coalescing offset arithmetic
Use cases
- Decode high-volume numeric result sets from ClickHouse queries using the RowBinary format
- Encode bulk inserts with wide numerics or fixed-width binary data into RowBinary payloads
- Stream columnar data from ClickHouse into Node.js applications with minimal overhead
- Parse RowBinary responses when JSON formats would be slower due to data shape (wide numerics, binary blobs)
- Generate specialized codecs for known schemas to avoid runtime type dispatch
- Node.js backend developers working with ClickHouse
- Data engineers optimizing throughput for numeric-heavy or binary-heavy datasets
- Teams building high-performance analytics pipelines with ClickHouse
- Developers choosing between RowBinary and JSON/CSV/Native formats
clickhouse-js-node-rowbinary FAQ
Prefer JSON (JSONEachRow, etc.) when results are mostly strings or you access every field randomly — V8's JSON.parse is heavily optimized. RowBinary wins for wide numerics (Int128/Int256, Decimal128/Decimal256), binary blobs (IPv4, IPv6, UUID, FixedString), and high-volume fixed-width numeric columns.
Use Native format when your goal is columnar load and client-side analytics (fold/scan/filter columns, feed typed arrays to a Worker or WASM), since Native is column-major and loads straight into typed arrays with no transpose.
RowBinary is little-endian only. Always read and write multi-byte numbers with DataView accessors passing a literal true for the littleEndian flag.
No, this skill is Node.js only. For browser environments, use @clickhouse/client-web instead.
Inline their bodies into your generated codec rather than calling them. This keeps the row loop straight-line with no per-field indirection, allowing the fixed-width coalescing to fold offset arithmetic together for better performance.
Full instructions (SKILL.md)
Source of truth, from clickhouse/agent-skills.
name: clickhouse-js-node-rowbinary
description: >
Generate TypeScript/JavaScript code that reads/decodes AND writes/encodes
ClickHouse RowBinary streams for the ClickHouse HTTP server.
Use this skill whenever a user wants to parse or produce RowBinary,
RowBinaryWithNames, or RowBinaryWithNamesAndTypes.
Node.js only, doesn't cover browsers.
ClickHouse JS RowBinary Codec Generator for Node.js
This skill generates both directions of the wire format: readers (decode bytes → values) and writers (encode values → bytes, the mirror). A given task normally needs only one side. This file is the shared entry point — the format gate plus the principles common to both directions; the per-direction decisions, guidance, and the per-type reference tables live in two sibling files.
Pick your side — read only the one you need:
- Decoding a
RowBinary*response from ClickHouse into JS values → reader.md. Streaming vs whole-buffer, row-objects vs columnar, fixed vs runtime schema, and the per-type reader reference. - Encoding JS values into a
RowBinarypayload to send to ClickHouse → writer.md. TheSink/writeXbuilding blocks,writeRowsstreaming, and the per-type writer reference.
The per-type code is real, split by direction under src/readers/ and
src/writers/.
First: is RowBinary even the right format?
RowBinary exists for throughput, but it is not automatically the fastest path — match the format to the shape of the data before committing to a bespoke parser.
Prefer a JSON* format (e.g. JSONEachRow) when the result is mostly
strings / JSON-like values that you consume wholesale — randomly accessing
essentially every field, running string/regexp methods on them, treating values
as text. V8's native JSON.parse is heavily optimized C++ and builds JS strings
and objects faster than a JS-level RowBinary decoder can; pair it with HTTP
response compression (gzip / zstd, which crushes JSON's repetitive keys) and
the wire cost shrinks too.
RowBinary clearly wins when the result is dominated by:
- Wide numerics —
Int128/Int256/UInt128/UInt256,Decimal128/Decimal256. - Binary / fixed-width blobs —
IPv4,IPv6,UUID,FixedString. - High-volume fixed-width numeric columns generally, where each value is a
single
DataViewread.
Prefer the Native format when columnar load and client-side analytics are
the main goal (fold/scan/filter columns, feed typed arrays to a Worker or WASM).
Native is column-major, so it loads straight into one typed array per column
with no transpose.
For help choosing and consuming a JSON* format (or CSV / TSV) instead, use the
clickhouse-js-node-coding skill.
Core guidance (both directions)
These principles apply whether you are generating a reader or a writer; the side-specific operational guidance is in reader.md / writer.md.
-
Little-endian only. RowBinary is little-endian; target x86/ARM. Read and write every multi-byte number with
DataViewaccessors passing a literaltruefor thelittleEndianflag. -
Correct first, then optimize. First emit a correct codec built from the plain per-type API. Only after it's correct (and tested) specialize it. Don't bake performance assumptions in before correctness.
-
Monomorphize generic/composite types. Emit specialized, inlined code per type combination instead of passing functions as arguments where the type is known ahead of time.
-
Inline the leaf ops. The per-type
readX/writeXfunctions are the correct, composable reference; the generated codec should INLINE their bodies, not call them, so the row loop is straight-line with no per-field indirection (and so the fixed-width coalescing can fold the offset arithmetic together). -
Annotate the type per column. Inlining erases the type structure, so put a short comment above each column's encode/decode block naming the ClickHouse type it handles.
-
Shared scratch is not reentrant. Some hot methods reuse a module-level scratch buffer as a write-then-read pair — correct only because the access is fully synchronous. An
async/yieldboundary between populating and reading it corrupts the value. -
TypeScript by default. Generate TypeScript code and helpers unless the user explicitly asks for plain JavaScript.
Worked examples
Six end-to-end examples with real speedup are catalogued in EXAMPLES.md.
Out of scope
- JSON / CSV / TSV / Parquet parsing → use
clickhouse-js-node-coding. - Connection errors, hangs, type mismatches → use
clickhouse-js-node-troubleshooting. - Browser / Web Worker / Edge →
@clickhouse/client-web.
Still Stuck?
Related skills
More from clickhouse/agent-skills and the wider catalog.

clickhouse-js-node-troubleshooting
Troubleshoot and resolve common issues with the ClickHouse Node.js client (@clickhouse/client).

clickhouse-managed-postgres-rca
Root-cause analysis for ClickHouse-managed Postgres performance issues using Prometheus metrics and slow query patterns.

clickhousectl-cloud-deploy
Deploy ClickHouse to the cloud and manage production instances with clickhousectl.

clickhousectl-local-dev
Set up a local ClickHouse development environment with tables and sample data in minutes.

clickstack-otel-collector
Wire an OpenTelemetry collector into Managed ClickStack on ClickHouse Cloud and verify telemetry ingestion.

infra-clickhouse
Set up and manage ClickHouse locally for development or deploy to ClickHouse Cloud for production.