53 releases (31 major breaking)

Uses new Rust 2024

58.0.0 Feb 23, 2026
57.3.0 Feb 6, 2026
57.2.0 Jan 11, 2026
57.1.0 Nov 24, 2025
27.0.0 Nov 14, 2022

#247 in Encoding

Download history 617568/week @ 2025-11-19 348673/week @ 2025-11-26 524715/week @ 2025-12-03 643230/week @ 2025-12-10 550494/week @ 2025-12-17 208765/week @ 2025-12-24 283014/week @ 2025-12-31 516734/week @ 2026-01-07 469188/week @ 2026-01-14 541306/week @ 2026-01-21 479753/week @ 2026-01-28 516495/week @ 2026-02-04 658455/week @ 2026-02-11 811744/week @ 2026-02-18 944495/week @ 2026-02-25 1105434/week @ 2026-03-04

3,624,041 downloads per month
Used in 237 crates (30 directly)

Apache-2.0

4MB
79K SLoC

Transfer data between the Arrow memory format and JSON line-delimited records.

See the module level documentation for the reader and writer for usage examples.

Binary Data uses Base16 Encoding

As per RFC7159 JSON cannot encode arbitrary binary data. This crate works around that limitation by encoding/decoding binary data as a hexadecimal string (i.e. Base16 encoding).

Note that Base16 only has 50% space efficiency (i.e., the encoded data is twice as large as the original). If that is an issue, we recommend to convert binary data to/from a different encoding format such as Base64 instead. See the following example for details.

Base64 Encoding Example

Base64 is a common binary-to-text encoding scheme with a space efficiency of 75%. The following example shows how to use the arrow_cast crate to encode binary data to Base64 before converting it to JSON and how to decode it back.

use arrow_cast::base64::{b64_decode, b64_encode, BASE64_STANDARD};
#
// The data we want to write
let input = BinaryArray::from(vec![b"\xDE\x00\xFF".as_ref()]);

// Base64 encode it to a string
let encoded: StringArray = b64_encode(&BASE64_STANDARD, &input);

// Write the StringArray to JSON
let batch = RecordBatch::try_from_iter([("col", Arc::new(encoded) as _)]).unwrap();
let mut buf = Vec::with_capacity(1024);
let mut writer = LineDelimitedWriter::new(&mut buf);
writer.write(&batch).unwrap();
writer.finish().unwrap();

// Read the JSON data
let cursor = Cursor::new(buf);
let mut reader = ReaderBuilder::new(batch.schema()).build(cursor).unwrap();
let batch = reader.next().unwrap().unwrap();

// Reverse the base64 encoding
let col: BinaryArray = batch.column(0).as_string::<i32>().clone().into();
let output = b64_decode(&BASE64_STANDARD, &col).unwrap();

assert_eq!(input, output);

Dependencies

~9.5MB
~167K SLoC