JSON → Apache Avro (.avsc)
Apache Avro & Confluent Schema Registry

JSON to Apache Avro Schema (.avsc) Converter

Convert JSON objects into standard Apache Avro schema definitions with record types, primitive fields, null union types, and doc annotations.

100% Client-Side Privacy
Zero Server Upload
Presets:
Avro Compiler Options & Schema Registry Settings
OrderFulfillmentEvent•smart
Field Casing:
Input21 fields
{
"type": "record",
"name": "OrderFulfillmentEvent",
"namespace": "com.ecommerce.events.orders",
"doc": "Standard Avro event schema compiled from JSON payload for OrderFulfillmentEvent",
"fields": [
{
"name": "eventId",
"type": {
"type": "string",
"logicalType": "uuid"
},
"doc": "Standard UUID identifier for eventId",
"default": "00000000-0000-0000-0000-000000000000"
},
{
"name": "orderNumber",
"type": "string",
"doc": "Text string for orderNumber",
"default": ""
},
{
"name": "eventType",
"type": "string",
"doc": "Text string for eventType",
"default": ""
},
{
"name": "occurredAt",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
},
"doc": "UTC timestamp (milliseconds since epoch) for occurredAt",
"default": 0
},
{
"name": "customer",
"type": {
"type": "map",
"values": "string"
},
"doc": "Associative string-keyed map for customer",
"default": {}
},
{
"name": "shippingAddress",
"type": {
"type": "map",
"values": "string"
},
"doc": "Associative string-keyed map for shippingAddress",
"default": {}
},
{
"name": "lineItems",
"type": {
"type": "array",
"items": {
"type": "record",
"name": "LineItemsItem",
"namespace": "com.ecommerce.events.orders",
"doc": "Standard Avro event schema compiled from JSON payload for LineItemsItem",
"fields": [
{
"name": "sku",
"type": "string",
"doc": "Text string for sku",
"default": ""
},
{
"name": "productName",
"type": "string",
"doc": "Text string for productName",
"default": ""
},
{
"name": "quantity",
"type": "int",
"doc": "Numeric value (int) for quantity",
"default": 0
},
{
"name": "unitPrice",
"type": "double",
"doc": "Numeric value (double) for unitPrice",
"default": 0
},
{
"name": "currency",
"type": "string",
"doc": "Text string for currency",
"default": ""
},
{
"name": "isTaxExempt",
"type": "boolean",
"doc": "Boolean flag for isTaxExempt",
"default": false
}
]
}
},
"doc": "List of LineItemsItem records for lineItems",
"default": []
},
{
"name": "subtotal",
"type": "double",
"doc": "Numeric value (double) for subtotal",
"default": 0
},
{
"name": "taxAmount",
"type": "double",
"doc": "Numeric value (double) for taxAmount",
"default": 0
},
{
"name": "shippingFee",
"type": "int",
"doc": "Numeric value (int) for shippingFee",
"default": 0
},
{
"name": "grandTotal",
"type": "double",
"doc": "Numeric value (double) for grandTotal",
"default": 0
},
{
"name": "currency",
"type": "string",
"doc": "Text string for currency",
"default": ""
},
{
"name": "couponCode",
"type": [
"null",
"string"
],
"doc": "Nullable string field for couponCode",
"default": null
},
{
"name": "payment",
"type": {
"type": "map",
"values": "string"
},
"doc": "Associative string-keyed map for payment",
"default": {}
},
{
"name": "notes",
"type": "string",
"doc": "Text string for notes",
"default": ""
}
]
}
Avro Fields & Attributes21 fields (1 nullable)
Hierarchy & Max DepthLevel 1 (1 records)
Logical Types & Compatibility2 logical types • BACKWARD

Zero-Knowledge Local Execution

All data processing, parsing, and compilation execute strictly inside your local browser memory. Zero external server uploads.

Sub-Millisecond AST Engine

All data payloads remain strictly local with zero external server communication.

Production Ready Export

Clean, optimized output formats ready for immediate deployment.

Technical Reference & Architecture Guide

JSON to Apache Avro Schema (.avsc) Converter — Reference Guide

Convert JSON payloads into production-ready Apache Avro schema (.avsc) definitions with custom namespaces, primitive and logical types, nullable union fields, and schema evolution defaults.

Key Parameters & Controls

recordNamestring

The top-level record identifier for the generated Avro schema, conforming to Avro naming conventions (must start with [A-Za-z_] and contain only alphanumeric characters or underscores).

Default: AutoRecord
namespacestring

The qualifying package or domain namespace (e.g., com.company.events) that scopes the Avro record and prevents collision in Schema Registry.

Default: com.example.avro
nullabilityModestring

Determines how optional or null-valued JSON fields are mapped. 'union_null_first' creates ["null", type] with default null for backward compatibility.

Default: union_null_first
inferLogicalTypesboolean

Enables automatic detection of ISO 8601 timestamps, UUID strings, and high-precision decimal numbers, converting them to Avro logicalType annotations (e.g., timestamp-millis, uuid).

Default: true

Pro Tips & Best Practices

Order Union Branches for Null

In Apache Avro specification 1.x, the default value must match the first branch of a union. For an optional field with "default": null, specify ["null", "string"] rather than ["string", "null"], otherwise schema validation will fail.

Defaults for Schema Evolution

When evolving schemas stored in Confluent Schema Registry or Apicurio, always assign a default value to newly introduced fields. This satisfies BACKWARD and FULL compatibility rules for downstream consumers reading older messages.

Map 64-Bit Integers to Long

JSON integers exceeding 2^31 - 1 (such as epoch timestamps or database auto-increment IDs) must map to Avro 'long' instead of 'int' to prevent silent integer overflow during binary serialization.

Common Gotchas & Troubleshooting

org.apache.avro.AvroTypeException: Default value for field does not match union branch 0

Rearrange the union type array so that the type of the default value is the first element. For "default": null, the type definition must begin with "null" as in ["null", "string"] or ["null", {"type": "record", ...}].

Confluent Schema Registry reports SchemaIncompatibleException on new fields

Add an explicit "default" attribute (such as null, empty string, or false) to any newly introduced field in your .avsc definition to preserve forward and backward compatibility.

Frequently Asked Questions

What is an Apache Avro .avsc schema file?▼

An .avsc file is a JSON-formatted definition of an Apache Avro schema. It defines record names, namespaces, field types, and default values used for binary serialization in data pipelines such as Apache Kafka, Apache Spark, and Hadoop.

How are JSON arrays and nested objects represented in Avro?▼

Nested JSON objects are converted into embedded Avro records with their own 'name', 'type': 'record', and 'fields'. JSON arrays are mapped to Avro 'array' types with an 'items' schema describing the element type.

Why is Avro binary serialization preferred over raw JSON in event streams?▼

Avro payloads are serialized into compact binary without repeating field names on each message. The schema is stored once in a Schema Registry, resulting in dramatically smaller network payloads, higher throughput, and strict contract governance.

What are Avro logical types and how does this converter handle them?▼

Logical types annotate primitive types with domain semantics. When inferLogicalTypes is enabled, date-time strings are converted to 'long' with logicalType 'timestamp-millis', and UUID strings are mapped to 'string' with logicalType 'uuid'.

Related Tools & Utilities

All Tools →