User Rating 0.0
Total Usage 0 times
Category JSON Tools
Input 0 chars
Drop .avsc or .json file here
Output

        
      
Ready Ctrl+Enter: Format • Ctrl+Shift+M: Minify
Is this tool helpful?

Your feedback helps us improve.

About

Apache Avro schemas define the structure of serialized data using a JSON-based format. A malformed schema - a missing type field, an undeclared named type in a union, or an invalid logical type annotation - will cause serialization failures at runtime, corrupting data pipelines and blocking downstream consumers. This tool parses Avro schema JSON, validates it against the Avro 1.11 specification (primitives: null, boolean, int, long, float, double, bytes, string; complex: record, enum, array, map, fixed, unions), and reports type-level errors with precise locations.

The formatter applies configurable indentation (2 or 4 spaces, or tabs), produces syntax-highlighted output with Avro-aware keyword coloring, and supports minification for compact storage. It approximates validation of logical types (date, timestamp-millis, decimal, uuid) but does not perform full schema resolution across multiple files. For multi-file schema registries, validate each file independently and verify cross-references manually.

avro avro schema avro formatter avro validator json formatter schema tools apache avro data serialization

Formulas

Avro schema validation follows a recursive type-resolution algorithm. For each node in the JSON structure, the validator determines the type category and checks required attributes.

validate(node)

{
VALID if node {null, boolean, int, long, float, double, bytes, string}validateRecord(node) if node.type = recordvalidateEnum(node) if node.type = enumvalidateArray(node) if node.type = arrayvalidateUnion(node) if isArray(node)ERROR otherwise

Where validateRecord(node) checks: node.name must exist and match the pattern [A-Za-z_][A-Za-z0-9_]*. node.fields must be a non-empty array. Each field must have name and type, where type is recursively validated. validateEnum(node) checks that symbols is a non-empty array of unique strings. validateUnion(node) verifies no duplicate types and no nested unions (unions within unions are forbidden by the Avro spec).

The name validation regex: pattern = /^[A-Za-z_][A-Za-z0-9_]*$/. Namespace validation: nsPattern = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.

Reference Data

Type CategoryType NameJSON RepresentationDescriptionExample
Primitivenull"null"No value"null"
Primitiveboolean"boolean"Binary value"boolean"
Primitiveint"int"32-bit signed integer"int"
Primitivelong"long"64-bit signed integer"long"
Primitivefloat"float"32-bit IEEE 754 float"float"
Primitivedouble"double"64-bit IEEE 754 float"double"
Primitivebytes"bytes"Sequence of 8-bit unsigned bytes"bytes"
Primitivestring"string"Unicode character sequence"string"
Complexrecord{"type":"record",...}Named record with fieldsRequires name, fields
Complexenum{"type":"enum",...}Enumeration of symbolsRequires name, symbols
Complexarray{"type":"array",...}Ordered collectionRequires items
Complexmap{"type":"map",...}String-keyed dictionaryRequires values
Complexfixed{"type":"fixed",...}Fixed-size byte sequenceRequires name, size
ComplexUnion["null","string"]One of several typesJSON array of types
Logicaldate"logicalType":"date"Days since epoch (int)Base type must be int
Logicaltime-millis"logicalType":"time-millis"Milliseconds since midnight (int)Base type must be int
Logicaltime-micros"logicalType":"time-micros"Microseconds since midnight (long)Base type must be long
Logicaltimestamp-millis"logicalType":"timestamp-millis"Milliseconds since epoch (long)Base type must be long
Logicaltimestamp-micros"logicalType":"timestamp-micros"Microseconds since epoch (long)Base type must be long
Logicaldecimal"logicalType":"decimal"Arbitrary-precision decimalBase: bytes or fixed; requires precision, scale
Logicaluuid"logicalType":"uuid"RFC 4122 UUIDBase type must be string
Logicalduration"logicalType":"duration"12-byte fixed durationBase: fixed with size = 12
Field AttrnameStringField/type identifierMust match [A-Za-z_][A-Za-z0-9_]*
Field AttrdocStringDocumentation stringOptional on records, fields, enums
Field AttrdefaultAnyDefault value for fieldMust match field type; union default matches first type
Field AttrorderStringSort order"ascending", "descending", "ignore"
Field AttraliasesArrayAlternative namesArray of strings
Schema AttrnamespaceStringDot-separated namespace"com.example.avro"

Frequently Asked Questions

The Avro specification explicitly forbids unions containing more than one schema of the same type, except for named types (record, fixed, enum) which are disambiguated by their full name (namespace + name). If you declare ["string", "string"], serialization libraries will throw an AvroTypeException. This formatter detects duplicate primitive types in unions and flags them as errors.
In Avro, the default value of a union field must match the first type in the union array. For example, if the union is ["null", "string"], the default must be null. If the union is ["string", "null"], the default must be a string value. This is the most common source of schema evolution errors. Reversing union order without updating defaults will break reader compatibility.
No. This formatter validates a single schema document in isolation. If your schema references a named type (e.g., "com.example.Address") defined in another file, the validator will flag it as an unresolved type. For multi-file schema registries, validate each file separately and manually verify that all named type references resolve to defined types across your registry.
Logical types are annotations on primitive or fixed types. The base type constraints are strict: date requires int, time-millis requires int, time-micros requires long, timestamp-millis and timestamp-micros require long, decimal requires bytes or fixed (plus precision and scale attributes), uuid requires string, and duration requires fixed with size exactly 12. A mismatch causes serialization failure.
No. Avro schemas are strict JSON. JSON does not permit comments (// or /* */) or trailing commas after the last element in arrays or objects. If your schema contains these, JSON.parse will fail before any Avro-specific validation occurs. This formatter reports the exact line and column of JSON syntax errors to help locate the problem.
Avro uses field names (not positions) for schema resolution between writer and reader schemas. The order attribute on fields (ascending, descending, ignore) only affects sort comparison in MapReduce contexts. Adding or removing fields is safe only if removed fields had defaults and new fields have defaults. This formatter validates that the order attribute, when present, is one of the three permitted values.