To see usage, you need to have Java 8 installed. Next, download latest release version from here or using command below.

curl -L -O https://github.com/rkluszczynski/avro-cli/releases/download/avro-cli-0.2.5/avro-cli-0.2.5.jar

Finally, just type:

java -jar avro-cli-0.2.5.jar 

to print help.


convert: Avro <-> JSON conversion

Note, that this conversion is without schema included in Avro files.

Avro <-> JSON conversion (without schema included).
Usage: convert [options]
    --inputFile, -i
      Source file with message.
      Default: -
    --outputFile, -o
      Target file of converted message.
      Default: -
    --rawAvroConversion, -r
      Using raw Avro conversion.
      Default: false
  * --schema, -s
      Source of schema to read.
    --toAvro, -a
      Convert from JSON to Avro.
      Default: false
    --toJson, -j
      Convert from Avro to JSON.
      Default: false

Example of usage printing JSON from Avro message to standard output:

java -jar avro-cli-0.2.5.jar convert -j -s schema-friendly-union.avsc -i message-friendly-union.avro 

where files are here.

fingerprint: Prints fingerprint of schema canonical form

Usage: fingerprint [options]
    --algorithm, -a
      Algorithm code for fingerprint (i.e. CRC-64-AVRO, MD5, SHA-256). Default 
      is Rabin fingerprint.
  * --schema, -s
      Source of schema to read.

normalize: Normalize schema to canonical parsing form

Usage: normalize [options]
    --outputFile, -o
      Target file of normalized schema. Default is standard output.
      Default: -
  * --schema, -s
      Source of schema to read.

validate: Native Avro validation

Usage: validate [options]
    --compatibility, -c
      One of compatibility strategy.
      Default: FULL
      Possible Values: [BACKWARD, FORWARD, FULL]
    --latest, -l
      Use only latest validator.
      Default: false
    --previousSchema, -p
      Sources of previous schemas in order of appearance in command line.
      Default: []
  * --schema, -s
      Source of schema to read.

Example of usage:

java -jar avro-cli-0.2.5.jar validate -c backward -s schema2-string-null-field.json -p schema1-string-field.json 

where files can bee seen here.

Schema sources

As of version 0.2.1 one can use URL address as schema source. For testing just start simple HTTP server in resources folder to serve schemas files.

( cd src/test/resources/ && python -m SimpleHTTPServer 8000 )

Finally, validate schema against empty history using command below.

java -jar avro-cli-0.2.5.jar validate -s http://localhost:8000/schema-no-fields.avsc