Data Formats: JSON, CSV, Parquet, Avro, and ORC Explained
Compare data formats — JSON, CSV, Parquet, Avro, and ORC — covering structure, compression, schema handling, and when to use each in pipelines.
JSON and CSV are convenient interchange formats, Parquet and ORC store columnar data for analytical reads, and Avro serializes records with a writer schema. File size and query speed depend on the data, codec, writer settings, and workload, so compare formats on the same representative input before choosing one.
Data Formats: JSON, CSV, Parquet, Avro, and ORC Explained
Data formats affect storage, query behavior, and how systems interpret records. The right choice depends on how the data is written and read, which engines need to support it, and how schemas change.
This post compares five established formats used in data systems: JSON, CSV, Parquet, Avro, and ORC. It focuses on structure, schema handling, and the workload factors that affect format choice.
JSON: Flexibility at a Cost
JSON (JavaScript Object Notation) is the dominant format for APIs and semi-structured data. It stores data as key-value pairs nested into objects and arrays. Human-readable, flexible, and everywhere.
{
"order_id": "ORD-12345",
"customer": {
"id": "CUST-789",
"name": "Priya Sharma",
"email": "priya@example.com"
},
"items": [
{ "product": "wireless-headphones", "qty": 2, "price": 79.99 },
{ "product": "usb-c-cable", "qty": 1, "price": 12.99 }
],
"total": 172.97,
"timestamp": "2026-03-27T10:23:45Z"
}
Each JSON object carries field names, but JSON does not guarantee that a schema change will be safe for every reader. Validate payloads against the expectations of their consumers.
JSON works well for event payloads, configuration files, and data exchange between services. For repeated analytical scans, compare its parse and scan cost with a columnar format on the target engine.
JSON trade-offs
| Aspect | Assessment |
|---|---|
| Readability | Excellent — human-readable |
| Schema evolution | Flexible syntax, but compatibility depends on readers |
| Storage efficiency | Repeated field names can add overhead |
| Query performance | Depends on parser, compression, and query shape |
| Compression | Text compresses; results depend on the data and codec |
CSV: Simple but Fragile
CSV (Comma-Separated Values) is a widely supported plain-text format for tabular data exchange. Records are commonly separated by lines, with commas delimiting fields and quoting rules for values that contain delimiters.
order_id,customer_id,product,qty,price,total
ORD-12345,CUST-789,wireless-headphones,2,79.99,172.97
ORD-12346,CUST-456,laptop-stand,1,45.00,45.00
The format is simple to inspect and widely supported. A CSV file does not carry a universally enforced schema or preserve types by itself, and it does not provide columnar access. Readers must agree on quoting, delimiters, encoding, and null representation.
CSV has no standard way to represent dates versus strings versus numbers. A column of dates arrives as text that downstream systems must parse. Null values appear as empty fields or magic strings like “NULL” or “N/A” that nobody standardized.
CSV can work well for flat exports and interchange when the producer and reader agree on those conventions. For production pipelines, make the parsing and type rules explicit or consider a format that carries schema information.
Parquet: Columnar for Analytical Workloads
Parquet is a columnar storage format built for analytical queries. It stores data column-by-column rather than row-by-row, which means scanning a specific column reads only that column’s data from disk.
Parquet was designed for analytical storage in the Hadoop ecosystem and is widely supported by data tools. It supports nested data and stores values in a column-oriented layout.
import pyarrow as pa
import pyarrow.parquet as pq
# Write a Parquet file
table = pa.table({
'order_id': ['ORD-12345', 'ORD-12346'],
'customer_id': ['CUST-789', 'CUST-456'],
'total': [172.97, 45.00]
})
pq.write_table(table, 'orders.parquet')
# Read only specific columns (column pruning)
table = pq.read_table('orders.parquet', columns=['order_id', 'total'])
Parquet files embed a schema in the file footer and encode data using techniques like dictionary encoding and run-length encoding. A column of repeated category values compresses dramatically because the same strings appear contiguously.
Parquet can reduce bytes read when a query projects a subset of columns. Its storage size and speed depend on the schema, values, codec, row-group settings, and query. Measure it against the other formats you are considering.
For more on how Parquet fits into data lakes versus data warehouses, see Data Warehousing.
Avro: Row-Based with Schema Evolution
Avro is a binary serialization format used for data exchange, including in Hadoop and Kafka systems. Its encoding is record-oriented, while Parquet and ORC are columnar file formats. Which one writes faster depends on the writer, codec, batch size, and workload.
Avro’s distinguishing feature is its schema. In an object container file, the writer schema is stored in the file header; a streaming system may keep schemas in a separate registry. Records are encoded against the schema rather than repeating field names for every row.
{
"type": "record",
"name": "Order",
"fields": [
{ "name": "order_id", "type": "string" },
{ "name": "customer_id", "type": "string" },
{ "name": "total", "type": "double" },
{
"name": "timestamp",
"type": { "type": "long", "logicalType": "timestamp-millis" }
}
]
}
Avro defines writer and reader schema resolution rules. Some changes, such as adding a field with a reader default, can be compatible; other changes depend on the old and new schemas and the consumers. Test compatibility rather than assuming every schema change is safe.
Avro uses binary encoding. For Kafka producers and consumers, a schema registry can distribute schemas and enforce a compatibility policy; the registry is a separate service, not part of the Avro file format.
ORC: Hive’s Columnar Format
ORC (Optimized Row Columnar) is a columnar format that originated in the Hive ecosystem. It uses stripes, type-aware encodings, and file statistics that supported engines can use to skip data.
# Example ORC file inspection
hive --orc-file-info --file orders.orc
ORC supports statistics, optional indexes such as bloom filters, and complex types. Hive ACID behavior is provided by Hive’s table and transaction layer; the ORC file format alone does not make writes transactional.
| Decision factor | Parquet | ORC |
|---|---|---|
| Layout | Columnar, with row groups and column chunks | Columnar, grouped into stripes |
| Useful when | Target engines already support it and queries benefit from column projection | Target engines use ORC statistics, indexes, or Hive integration |
| Compare before choosing | Codec, row-group size, schema, and engine version | Codec, stripe size, schema, and engine version |
Both formats support column projection and metadata-based pruning, but the details and available features vary by writer and reader. Check the documentation for the exact versions in your pipeline and benchmark with the same data and codec.
Choosing a Format
The right format depends on your workload pattern.
| Workload or constraint | Candidate | Check before adopting |
|---|---|---|
| Human-readable API payloads or flexible event exchange | JSON | Payload size, parsing cost, and schema validation |
| Flat exports for tools that expect text | CSV | Delimiters, quoting, null representation, and type inference |
| Analytics that scans selected columns | Parquet or ORC | Engine support, codecs, row-group/stripe settings, and observed query scans |
| Record serialization with explicit writer schemas | Avro | Reader/writer compatibility policy and schema registry behavior, if used |
There is no format that is the right default for every lake. Start with the engines and query patterns you need to support, then benchmark the finalists.
Data Format Selection Flow
Choosing the right format is a decision tree. This diagram maps the selection logic:
flowchart TD
Start[New format decision] --> Workload{Workload type?}
Workload -->|APIs / Web| JSON
Workload -->|One-time export| CSV
Workload -->|Read-heavy analytics| Analytics{Column projections?}
Analytics -->|Wide reads / aggregations| Parquet
Analytics -->|Hive / Spark aggregations| ORC
Workload -->|Streaming with schema changes| Avro
Workload -->|General-purpose lake| Engines{Which candidate formats do your query engines support?}
Engines -->|Supported candidates| Benchmark[Benchmark candidates on the same data, codec, and queries]
Benchmark --> Choice[Choose from measured results and operational constraints]
Use the flow to narrow the options, then check the candidate against the engines and queries you actually run. When both Parquet and ORC are supported, benchmark them on identical input and settings.
Common Anti-Patterns
Using JSON for analytical workloads
JSON repeats field names in each object, which can add storage and parsing work for repeated records. The effect depends on field names, value sizes, nesting, and compression.
JSON readers generally parse the object structure before selecting fields. A columnar format can avoid reading unrelated column pages when the engine supports projection and the file layout allows it.
For repeated analytical scans, benchmark JSON against a columnar candidate on the target engine instead of assuming the result from format alone.
Using CSV for typed data
CSV has no universally enforced type system. Importing tools infer or assign types, so pipelines should define how dates, numbers, quoting, and nulls are interpreted.
Null handling needs an agreed convention because CSV does not define one universal null representation. An export might use an empty field or a sentinel such as NULL; the reader should be configured to interpret it explicitly so missing values are not mistaken for strings or zeros.
Type inference can also vary between readers. Define and validate types at ingestion, especially for dates, decimals, identifiers, and nullable fields. CSV remains useful when a plain-text interchange file is the required interface.
Choosing Parquet for write-heavy workloads
Parquet writers commonly build columnar data in batches, so small, frequent writes can produce many small files or incur compaction work in some storage systems. Avro is record-oriented and may suit record serialization, but write throughput depends on the producer, codec, batching, and surrounding system. Benchmark the end-to-end pipeline before choosing a write format.
Write and read formats can differ. Some pipelines serialize incoming records with Avro and compact them into Parquet or ORC for analytics, but that choice should follow throughput, compatibility, and reader support measured in the target system.
Benchmark formats on the same workload
Do not plan storage from a generic compression ratio. The result changes with field names, value cardinality, null rate, nesting, codec, writer settings, and query shape. Use a repeatable comparison:
- Create one representative input dataset with a fixed random seed, row count, schema, null rate, and value distributions. Record its checksum.
- Write that same logical data to each candidate format. Use the same codec where the writer supports it; record codec level, row-group or stripe size, and all library and engine versions. Mark results as non-comparable when a setting cannot be matched.
- Run the same projection-and-filter query and the same full-scan aggregation for each format. Record output bytes, bytes scanned, elapsed time, and peak memory. Run each query several times and report cold-cache and warm-cache results separately when the engine permits.
- Save the hardware, operating system, engine configuration, command lines, and results with the benchmark. Re-run after changing the schema, codec, or reader version.
For an ORC-versus-Parquet test, keep the input rows, schema, codec, and query identical. The Parquet documentation, Avro documentation, and ORC specification describe file-level behavior; engine support and tuning still vary by version. For related reading on how data formats interact with storage systems, see Object Storage and Database Replication.
Conclusion
Data formats make different trade-offs. CSV and JSON are easy to exchange but leave more interpretation to the reader. Parquet and ORC store columnar data for analytical engines. Avro carries a schema with serialized records; compatibility still depends on the writer and reader schemas.
Choose based on the engines, schema-change policy, and measured read and write patterns in your pipeline. A format choice affects storage and query costs, but the result needs to be measured on your workload.
Quick Recap
- JSON: Useful for APIs and event payloads; compare parsing and scan costs before using it for repeated analytics.
- CSV: Widely supported for text exchange, but producers and readers need an agreed convention for types, quoting, and nulls.
- Parquet: Columnar file format; test it with the engines and queries you use.
- Avro: Record-oriented serialization with schema resolution rules; validate changes against consumers.
- ORC: Columnar file format with stripes and optional statistics and indexes; Hive transactions are a separate layer.
- Compare candidates on the same data, codec, query, and software versions.
Category
Related Posts
Schema Evolution: Managing Changing Data Structures
Schema evolution lets pipelines handle changing data structures without breaking consumers. Learn backward and forward compatibility strategies.
Schema Registry: Enforcing Data Contracts
Learn how Schema Registry prevents data incompatibilities in distributed systems, supports schema evolution, and enables reliable streaming pipelines.
JSON, Content Types, and API Serialization Explained
Learn how JSON representations, media types, and serialization rules shape API compatibility, validation, and reliable client-server data exchange.