Avro Formatter

Format, validate, and canonicalize Apache Avro schemas.

0 chars
0 words
0 lines
0 chars
0 words
0 lines

Avro Formatter – Format and Validate Avro Schemas

Apache Avro schemas are JSON documents that describe records for Kafka topics, Hadoop files, and RPC messages. The Avro formatter pretty-prints .avsc files and, unlike a plain JSON formatter, checks the schema against the Avro specification so you catch problems before a schema registry rejects them.

Three modes

  • Beautify – indented JSON with 2 or 4 spaces or tabs.
  • Minify – compact single-line JSON, ready to embed in code or send to a registry API.
  • Canonical form – the Avro Parsing Canonical Form: names fully qualified, attributes such as doc, default, and aliases removed, keys ordered, and whitespace stripped. Two schemas that are equivalent for reading data produce the same canonical form, which is what fingerprints (like the CRC-64-AVRO used in single-object encoding) are calculated from.

Schema validation

Below the editors you see whether the schema is valid. The validator checks:

  • Every type is a primitive (null, boolean, int, long, float, double, bytes, string), a complex type, or a named type defined earlier.
  • Records have a valid name and a fields array with unique field names and types.
  • Enums have unique, valid symbols, and their default is one of them.
  • Arrays have items, maps have values, and fixed types have a size.
  • Unions do not contain duplicate types or nested unions.
  • Logical types annotate the right type: decimal on bytes/fixed with a precision, timestamp-millis on long, date on int, uuid on string.
  • Named types are not defined twice.

Errors are listed with a JSON path such as $.fields[2].type.symbols[1] so you can find them quickly.

Validate plain JSON with the JSON Validator, explore large schemas in the JSON Viewer, or compare two schema versions with JSON Diff.

Frequently Asked Questions

It is a normalized version of a schema defined by the Avro specification. Attributes that don't affect reading data, like doc and default, are removed, names are fully qualified, and whitespace is stripped. Equivalent schemas have the same canonical form and fingerprint.

No. It validates a single schema. Backward and forward compatibility checks require comparing two schemas, which schema registries do when you register a new version.

No. This tool works with schemas (.avsc JSON). Binary .avro data files contain a schema header plus encoded records and need an Avro library to decode.

Typical causes are a reference to a type that is not defined yet, a duplicate field name, an enum default that is not a symbol, or a logical type on the wrong base type. The error list shows the exact path.