Support
Data Engineering

How to Open and Read an Avro File Without Java

November 17, 2026 · 5 min read

You have an .avro file from a Kafka export, a Spark job or a data lake, and you open it in a text editor: a few readable words at the top, then binary noise. Nothing is wrong with the file. Avro is a binary format, so you need something that understands it. This guide shows three ways to read one, and what is inside the file.

What is inside an Avro file

A file written by an Avro library is an object container file. It starts with the four bytes O b j 1 (the last one is the byte 0x01). Next comes a header that holds the writer schema as JSON and the name of the compression codec. After the header, the records are stored in blocks, each followed by a 16-byte sync marker.

That is why the schema is the first thing you can read in a text editor, and why you never need a separate schema file to open a container file: the schema travels with the data. (A single Avro-encoded Kafka message is different. It carries no schema, only an ID that points to one in a registry; see How to Decode Kafka Messages.)

The codec is usually null (no compression), deflate or snappy; some writers use zstandard. A reader has to support the codec the writer chose, which is a common reason a tool fails on one file and works on another.

Option 1: in the browser, with nothing to install

Open the Hexabench Avro Viewer and drop the file on the page. It reads the header, decodes the records and shows them as a table. The Schema tab shows the fields with their types and whether each can be null, plus the full writer schema as JSON, which you can copy or download as an .avsc file. You can filter the rows, run SQL on them, and export the records as JSON or CSV. To get the whole file as JSON or JSON Lines, with the schema and a preview first, use the Avro to JSON Converter.

The file is read in your browser and is not uploaded to a server, so it is a reasonable choice for a file that holds real data. If you only want to see how it works, the page has a sample file you can load with one click.

Option 2: with Python

The fastavro package reads container files without Java:

pip install fastavro

from fastavro import reader

with open("events.avro", "rb") as f:
    avro_reader = reader(f)
    print(avro_reader.writer_schema)   # the schema from the header
    for record in avro_reader:
        print(record)

Snappy and Zstandard files also need their codec packages (python-snappy, zstandard). If you load the records into a pandas DataFrame with pd.DataFrame(list(avro_reader)), nested records and unions become Python dicts and values, so check the columns before you rely on them.

Option 3: with avro-tools (needs Java)

The Apache Avro project ships a command-line jar. You need a Java runtime and the jar for your Avro version:

java -jar avro-tools-<version>.jar getschema events.avro
java -jar avro-tools-<version>.jar tojson events.avro

getschema prints the writer schema and tojson prints one JSON object per record. This is the reference implementation, which makes it the best check when two tools disagree about a file.

Common problems

"Not an Avro data file" or a magic-byte error. The file does not start with Obj1. It may be a single Kafka message (starts with a zero byte, see the guide linked above), a JSON file with the wrong extension, or a file that was truncated or downloaded in text mode.

It fails on one file but not another. Look at the codec in the header. The two files may use different codecs, and the tool or library you use may not have the one that failed installed.

A column shows up as a long number or a string. Avro stores dates and decimals as long, int or bytes plus a logical type in the schema, such as timestamp-millis. Read the schema to see how a value should be interpreted.

The file is huge. A browser loads the whole file into memory. For files of many hundreds of megabytes, use avro-tools or fastavro on a machine with enough memory, or convert it to Parquet first.

Avro, Parquet and JSON: which is which

Avro stores whole records one after another (row-based), which suits writing streams, so you meet it in Kafka topics and ingestion pipelines. Parquet stores each column together, which suits analytics queries. If you want to inspect a Parquet file instead, use the Parquet Viewer; to look at the structure of another binary format, the Protobuf Viewer works the same way.

Open the Avro Viewer → · Back to Blog