Apache Avro is a compact, schema-driven serialization format widely used with Kafka and the Confluent Schema Registry. An Avro schema is itself a JSON document describing records, enums, arrays, maps, unions, and fixed-size byte blobs. When schemas grow nested it becomes hard to read the raw JSON, so this viewer turns it into a collapsible tree and checks its structure.
How it works
The parser walks the schema recursively according to the Avro specification:
- A string that is a primitive name (
int,string, etc.) is a leaf; any other string is treated as a reference to a previously named type. - A JSON array is a union — each element is a branch, commonly used as
["null", "string"]for nullable fields. - A record must carry a
nameand afieldsarray; each field needs anameand atype, and an optionaldefaultis shown alongside it. - enum needs
symbols, array needsitems, map needsvalues, and fixed needs a numericsize.
As it walks, it collects any structural violations and reports them with a JSON-path-style location so you can jump straight to the problem.
Example schema and rendered output
A minimal Avro record for a user event:
{
"type": "record",
"name": "UserEvent",
"namespace": "com.example",
"fields": [
{ "name": "userId", "type": "string" },
{ "name": "email", "type": ["null", "string"], "default": null },
{ "name": "role", "type": { "type": "enum", "name": "Role", "symbols": ["ADMIN", "USER", "GUEST"] } },
{ "name": "tags", "type": { "type": "array", "items": "string" }, "default": [] }
]
}
The viewer renders this as a tree rooted at UserEvent (record) with four child field nodes. The email field becomes a union node with null and string branches, showing the default value alongside. The role field expands to show ADMIN | USER | GUEST. The tags field shows array → string.
Common structural errors caught
| Error | Location example | Why it matters |
|---|---|---|
Record missing fields | UserEvent | A record without fields is invalid and unusable as a schema |
Field missing name | fields[2] | Consumers reference fields by name; nameless fields cannot be deserialized |
Enum with empty symbols | fields[2].type | An enum with no values can never hold a valid state |
Fixed missing size | checksum (fixed) | Fixed types have a known byte length; omitting it breaks encoding |
| Union default type mismatch | email.default | The default for a union must match the first branch type (if null first, default must be null) |
What structural validity does not check
This viewer confirms the schema is well-formed JSON that follows Avro’s type rules. It does not check:
- Compatibility with a registered schema version. Adding a field without a default breaks backward compatibility; removing a field without checking consumers breaks forward compatibility. The Confluent Schema Registry enforces these rules when you register a new version.
- Whether referenced named types exist. If your schema references a named type (e.g.
"type": "com.example.Address") defined in a separate file, this viewer treats it as an external reference and does not validate its definition. - Data conformance. This tool validates the schema document structure, not individual Avro-encoded records.
For producer/consumer compatibility testing, a clean structural pass here is the prerequisite, but you still need the Schema Registry’s compatibility mode (BACKWARD, FORWARD, FULL) for complete validation.