jsondecode.com logo

JSON to Apache Avro Schema Generator — Free Online Tool

Convert JSON to an Apache Avro schema in JSON format with namespace, type, and fields definitions using AI. Supports null unions and nested records. Free, no sign-up.

JSON to BigQuery Schema Converter — Free Online ToolJSON to React Flow Diagram — Convert JSON Online FreeJSON to Go Struct with BSON Tags — Free Online ToolJSON to TypeScript Interface Generator — Free OnlineJSON to YAML Converter — Convert JSON to YAML OnlineJSON to CSV Converter — Export JSON Array to CSV FreeJSON to Python Dataclass Generator — Free Online ToolJSON to SQL INSERT Statement Generator — Free OnlineJSON to Markdown Table Converter — Free Online ToolJSON to XML Converter — Convert JSON to XML Online FreeJSON to HTML Table Converter — Free Online ToolYAML to JSON Converter — Convert YAML to JSON Online FreeXML to JSON Converter — Convert XML to JSON Online FreeJSON to JSON Schema Generator — Free Online ToolJSON to GraphQL Schema Generator — Free Online ToolRuby to JSON Converter — Convert Ruby Hashes to JSON OnlineJSON to C# Class Generator — Free Online ToolJSON to Java Class (POJO) Generator — Free Online ToolJSON to Kotlin Data Class Generator — Free Online ToolJSON to Rust Struct Generator — Free Online ToolJSON to PHP Array Converter — Free Online ToolCSV to JSON Converter — Free Online ToolJSON to Dart Class Generator — Free Online ToolJSON to Swift Struct (Codable) Generator — Free OnlineJSON to Terraform HCL Variables Converter — Free OnlineJSON to Mongoose Schema Generator — Free Online ToolJSON to Prisma Schema Model Generator — Free OnlineJSON to Protocol Buffer (proto3) Generator — Free OnlineJSON to TOML Config Format Converter — Free Online ToolTOML to JSON Converter — Convert TOML to JSON Online FreeJSON to OpenAPI 3.0 Schema Component — Free Online ToolJSON to R Data Frame Code Generator — Free Online ToolJSON to Lua Table Syntax Converter — Free Online ToolJSON to Zod Schema (TypeScript) Generator — Free OnlineJSON to Scala Case Class with Circe Codec — Free OnlineJSON to PowerShell Hashtable Converter — Free Online Tool

JSON to Apache Avro Schema Generator — Free Online Tool

About JSON to Apache Avro Schema Generator — Free Online Tool

This tool converts any JSON object or array into an Apache Avro schema, inferring record names, field types, and nullable unions so you can immediately use the output in Kafka pipelines, Hadoop jobs, or any Avro-based data platform. Developers use it to eliminate hand-authoring verbose Avro JSON schemas and to ensure schema registry compatibility without trial-and-error cycles.

JSON to Avro Type Mapping

JSON TypeAvro TypeNotes
string"string"UTF-8 encoded; maps directly to Avro string primitive
number (integer)"long"Avro has no generic number; integers default to long (64-bit)
number (float)"double"Floating-point numbers map to double for maximum precision
boolean"boolean"Direct 1-to-1 mapping
null"null"Standalone null or combined in a union type
object{"type":"record",...}Becomes a named Avro record with a fields array
array{"type":"array",...}items field holds the inferred element type
null + value["null", "<type>"]Nullable fields become a union; null is always listed first per convention

Avro vs. Alternative Schema Formats

FeatureAvroJSON SchemaProtobufParquet
Schema languageJSONJSONProto IDLN/A (storage format)
Schema evolutionFull (reader/writer)LimitedField numbers requiredVia Hive/Spark metadata
Binary encodingYes (compact)NoYes (very compact)Yes (columnar)
Kafka ecosystem supportFirst-class (Confluent SR)PartialYesNo
Nullable fieldsUnion with null"nullable" keywordoptional keywordAll fields nullable
Self-describing binaryYes (includes schema)NoNoYes
Human-readable schemaYesYesYesNo

Frequently Asked Questions

What is an Avro schema and how is it structured?

An Avro schema is a JSON document that defines a data type used for serialization. Top-level schemas for records include a type of "record", a name, an optional namespace, and a fields array where each field has a name and a type. Primitive types like string, int, long, float, double, boolean, bytes, and null are referenced as JSON strings, while complex types like records, arrays, maps, and unions are JSON objects.

Why does JSON null map to a union in Avro instead of a simple null type?

Avro is strongly typed and does not allow a field to hold multiple types unless explicitly declared as a union. When a JSON field can be null or a value, Avro represents this as ["null", "string"] (or the relevant type), meaning the field accepts either. By convention, null is listed first in the union so the default value of null is valid without extra configuration. Omitting the union and using just the value type would cause deserialization errors whenever a null appears.

How do I use a generated Avro schema with Confluent Schema Registry?

POST the generated schema JSON to the Schema Registry REST API at /subjects/{topic-name}-value/versions with Content-Type application/vnd.schemaregistry.v1+json and a body of {"schema": "<escaped-schema-string>"}. The registry returns a schema ID you embed in Kafka message headers. Confluent's Java, Python, and Go serializers handle this automatically when you configure schema.registry.url in your producer/consumer settings.

Can Avro schema handle nested JSON objects and arrays?

Yes. Nested JSON objects become nested Avro record types, each requiring a unique name within the schema. Arrays become Avro array types with an items field that holds the inferred element type, which can itself be a record, primitive, or another array. Deep nesting is fully supported, but each nested record must have a distinct name to avoid schema conflicts in the Avro parser.

What is the difference between Avro "int" and "long" and which should I use?

Avro int is a 32-bit signed integer (range -2,147,483,648 to 2,147,483,647) while long is 64-bit (range ±9.2 × 10^18). JSON has no distinction between integer sizes, so converters typically default to long to avoid overflow for large IDs or timestamps. If you know your values fit within 32 bits and want to reduce schema size and serialization overhead, you can manually change the generated type to int.

If jsondecode.com saved you time, share it with your team

Free forever. No ads. No sign-up. Help other developers find it.