JSON To Avro Schema

Login

Email
Password

Don't have an account yet?

Go to Sign up

Input Data
Sample {{ showCoderInput ? 'Choose File' : 'Enter Data' }}

                                
Valid JSON Invalid JSON — Cannot convert to JSON Array
Output Data
{{ copied ? 'Copied!' : 'Copy to Clipboard' }} Download File
Properties
Convert JSON Array to Avro Schema online — paste, edit, and download Avro.

Record Name:
The name of the Avro record type in the schema.
Namespace:
Optional namespace to uniquely identify the Avro schema.
Output Format:
Schema + Data Schema Only Choose to output schema with data or schema definition only.
Indent:
2 spaces 4 spaces Tab Minified Number of spaces or tab character for indentation.
Smart Types:
Smart Types infers int/boolean/double.
Parse JSON:
Include Null adds null to union types.
Convert Restart

JSON to Avro Schema — Free Online Avro Schema Generator

What Is Apache Avro?

Apache Avro is a data serialization system that uses JSON-based schemas to define data structures, then serializes data in a compact binary format. It is a core technology in the Apache big data ecosystem.

Key properties:

PropertyDescription
Schema-firstData structure defined before serialization
JSON schemasSchemas written in JSON; data serialized in binary
Language-neutralSupports Java, Python, C, C++, C#, Go, Ruby, PHP, etc.
Compact binarySmaller than JSON; no field names in serialized data
Schema evolutionAdd fields without breaking backward compatibility
Self-describingData includes its schema

Where Apache Avro Is Used

Platform / Use CaseHow Avro Is Used
Apache KafkaDefault serialization format for Kafka messages (Confluent Schema Registry)
Apache HadoopData serialization for MapReduce, HDFS storage
Apache SparkAvro is a native data source format
Apache FlinkStream processing with Avro types
Apache NiFiData flow processing with Avro schemas
Confluent PlatformSchema Registry stores and manages Avro schemas
AWS GlueData Catalog uses Avro schemas for table definitions
Data lakesAvro is a common format in S3/GCS/ADLS data lakes
Event streamingHigh-throughput, schema-enforced event delivery

What Is an Avro Schema?

An Avro schema is a JSON document that defines the structure of serialized data. It specifies field names, types, and optional default values.

{
 "type": "record",
 "name": "User",
 "namespace": "com.example",
 "fields": [
   {"name": "id", "type": "int"},
   {"name": "name", "type": "string"},
   {"name": "email", "type": ["null", "string"], "default": null},
   {"name": "active", "type": "boolean"}
 ]
}

Avro Schema Components

ComponentDescriptionExample
typeSchema type"record", "array", "map"
nameRecord/type name"User"
namespaceUnique package identifier"com.example"
fieldsArray of field definitions[{"name": "id", "type": "int"}]
docDocumentation string"User record"

Avro Primitive Types

Avro TypeDescriptionJSON Example
nullNo valuenull
booleanTrue or falsetrue
int32-bit signed integer42
long64-bit signed integer9999999999
floatSingle precision (32-bit)3.14
doubleDouble precision (64-bit)3.141592653589793
bytesSequence of 8-bit bytes(binary)
stringUnicode character sequence"hello"

Avro Complex Types

TypeDescriptionExample
recordNamed fields (like a struct){"type": "record", "fields": [...]}
enumNamed set of values{"type": "enum", "symbols": ["A", "B"]}
arrayOrdered sequence{"type": "array", "items": "string"}
mapKey-value pairs{"type": "map", "values": "string"}
unionOne of multiple types["null", "string"]
fixedFixed-size bytes{"type": "fixed", "size": 16}

Avro vs. JSON vs. Protocol Buffers

FeatureAvroJSONProtocol Buffers
SchemaJSON-basedNone (optional).proto files
SerializationBinaryTextBinary
Schema evolutionBuilt-in (field ordering)ManualBuilt-in (field numbers)
Code generationOptionalN/ARequired (protoc)
Dynamic typingSupportedNativeNot supported
Null handlingUnion types (["null", "type"])Native nullOptional fields (proto3)
Primary ecosystemHadoop, KafkaWeb, APIsgRPC, Google
Best forBig data, event streamingAPIs, configRPC, microservices

JSON-to-Avro Type Mapping

Without Smart Types (All Strings)

JSON TypeAvro Type
Any valuestring

With Smart Types Enabled

JSON TypeJSON ExampleInferred Avro Type
String"hello"string
Integer (fits in int)42int
Integer (exceeds int)9999999999long
Float3.14double
Booleantrueboolean
Nullnullnull (added to union)
Object{...}Nested record
Array[...]array

Why Convert JSON to Avro Schema?

Use CaseDescription
Kafka migrationGenerate Avro schemas for Kafka topics currently using JSON
Schema RegistryRegister schemas in Confluent Schema Registry
Data lake setupDefine schemas for Parquet/Avro files in S3/GCS
Hadoop jobsCreate Avro schemas for MapReduce input/output
Spark data sourcesDefine schemas for Spark Avro data sources
API contractsDefine data contracts for event-driven architectures
DocumentationAuto-generate schemas from sample JSON for reference
Schema evolution planningStart with inferred schema, then refine for versioning

Core Features

1. Dual Input Modes

  • File Upload: Drag and drop or select a .json file.

  • Code Editor: Paste or type raw JSON with syntax highlighting and real-time validation.

2. Record Name

Sets the name field in the Avro schema. This identifies the record type.

{
 "type": "record",
 "name": "Order",
 ...
}

Use PascalCase by convention: User, Order, SensorReading, PageView.

3. Namespace

Sets the namespace field — a dot-separated identifier that uniquely qualifies the schema name.

{
 "type": "record",
 "name": "User",
 "namespace": "com.example.events",
 ...
}

Conventions:

  • Java-style: com.company.project.module

  • Domain-based: io.company.events

The fully qualified name becomes com.example.events.User.

4. Output Format

OptionOutput
Schema + DataAvro schema followed by the JSON data formatted according to the schema
Schema OnlyOnly the Avro schema definition (no data)

Use Schema Only for registering in Schema Registry. Use Schema + Data for documentation and testing.

5. Indent

Controls output JSON formatting:

OptionWhen to Use
2 spacesDefault — clean, readable
4 spacesDeeply nested schemas
TabMatch project conventions
MinifiedSmallest file size for storage

6. Smart Types

When enabled, the tool infers Avro types from JSON values instead of defaulting all fields to string.

Smart Types enabled:

{"name": "id", "type": "int"}
{"name": "price", "type": "double"}
{"name": "active", "type": "boolean"}

Smart Types disabled:

{"name": "id", "type": "string"}
{"name": "price", "type": "string"}
{"name": "active", "type": "string"}

Enable Smart Types for type-safe schemas. Disable for schemas where all values should be treated as strings (e.g., CSV imports with no type information).

7. Parse JSON — Include Null

When enabled, adds null to union types for fields that may contain null values.

Enabled:

{"name": "email", "type": ["null", "string"], "default": null}

Disabled:

{"name": "email", "type": "string"}

Enable this when your JSON data may contain null values. In Avro, nullable fields must use union types ["null", "type"]. Without this, null values in your data will cause serialization errors.

8. Privacy by Design

All processing runs entirely in your browser. No data is uploaded to any server.

How to Use This JSON to Avro Schema Generator

Step 1: Provide Your JSON Data

Choose one of two input methods:

  • Upload a file: Click "Choose File" and select a .json file, or drag it into the upload area.

  • Paste data: Click "Enter Data" to switch to the code editor. Paste your JSON array.

Important: The tool expects a JSON array of objects.

Step 2: Configure Avro Schema

Use the Properties panel on the right:

  1. Record Name: Enter a name (e.g., User, Order, Event).

  2. Namespace: Enter a namespace (e.g., com.example.events).

  3. Output Format: Choose Schema + Data or Schema Only.

  4. Indent: Select formatting style.

  5. Smart Types: Enable to infer int/boolean/double from JSON values.

  6. Parse JSON — Include Null: Enable to add null to union types.

Step 3: Convert

Click Convert. The Avro schema appears in the "Output Data" panel.

Step 4: Copy or Download

  • Click Copy to Clipboard to paste into your schema file.

  • Premium users can click Download File to save as .avsc.

Complete Example

Example — User Event Schema

Input JSON:

[
   {"id": 1, "name": "Alice", "email": "[email protected]", "active": true, "score": 95.5},
   {"id": 2, "name": "Bob", "email": null, "active": false, "score": 88.0},
   {"id": 3, "name": "Charlie", "email": "[email protected]", "active": true, "score": 72.3}
]

Configuration:

  • Record Name: UserEvent

  • Namespace: com.example.events

  • Output Format: Schema Only

  • Indent: 2 spaces

  • Smart Types: On

  • Include Null: On

Output:

{
 "type": "record",
 "name": "UserEvent",
 "namespace": "com.example.events",
 "fields": [
   {"name": "id", "type": "int"},
   {"name": "name", "type": "string"},
   {"name": "email", "type": ["null", "string"], "default": null},
   {"name": "active", "type": "boolean"},
   {"name": "score", "type": "double"}
 ]
}

Example — Kafka Order Events

Input JSON:

[
{"order_id": "ORD-001", "total": 149.99, "items": 3, "status": "shipped", "timestamp": 1715011200},
{"order_id": "ORD-002", "total": 59.50, "items": 1, "status": "pending", "timestamp": 1715011300}
]

Configuration:

  • Record Name: OrderEvent

  • Namespace: com.company.orders

  • Smart Types: On

  • Include Null: Off

Output:

{
 "type": "record",
 "name": "OrderEvent",
 "namespace": "com.company.orders",
 "fields": [
   {"name": "order_id", "type": "string"},
   {"name": "total", "type": "double"},
   {"name": "items", "type": "int"},
   {"name": "status", "type": "string"},
   {"name": "timestamp", "type": "long"}
 ]
}

Register in Confluent Schema Registry:

curl -X POST \
 http://localhost:8081/subjects/order-events-value/versions \
 -H "Content-Type: application/vnd.schemaregistry.v1+json" \
 -d '{"schema": "..."}'

Example — All Strings (Smart Types Off)

Configuration:

  • Smart Types: Off

Output:

{
 "type": "record",
 "name": "Data",
 "fields": [
   {"name": "id", "type": "string"},
   {"name": "name", "type": "string"},
   {"name": "active", "type": "string"}
 ]
}

Use this when all data should be treated as strings (e.g., CSV-to-Avro conversion with no type info).

Frequently Asked Questions (FAQ)

  • Does the tool upload my data?

    No. All conversion happens locally in your browser using JavaScript. Your data never leaves your device.

  • What is Apache Avro?

    Apache Avro is a data serialization system that uses JSON-based schemas and compact binary serialization. It is widely used in Apache Kafka, Hadoop, Spark, and big data pipelines.

  • What is an Avro schema?

    An Avro schema is a JSON document that defines the structure of serialized data — field names, types, namespaces, and defaults. Data is serialized in binary using the schema.

  • What is Smart Types?

    When enabled, Smart Types infers Avro types from JSON values: integers become int, floats become double, booleans become boolean. When disabled, all fields default to string.

  • What does Include Null do?

    It adds null to union types for fields that may contain null values. In Avro, nullable fields must use union types like ["null", "string"]. Without this, null values cause serialization errors.

  • What is a namespace?

    A namespace uniquely qualifies the schema name, similar to a Java package. Example: com.example.events. The fully qualified name becomes com.example.events.UserEvent.

  • What is the difference between Schema Only and Schema + Data?

    Schema Only outputs just the Avro schema definition. Schema + Data outputs the schema followed by the JSON data formatted according to it. Use Schema Only for Schema Registry registration.

  • What file extension should I use?

    Use .avsc for Avro Schema files and .avro for Avro data files.

  • Can I use the output with Confluent Schema Registry?

    Yes. The generated schema is standard Avro JSON format compatible with Confluent Schema Registry, Kafka producers/consumers, and all Avro implementations.

  • Is there a file size limit?

    The tool processes data entirely in your browser. Files up to 10 MB typically convert without issues on modern hardware.

Featured Tools

Featured tools that you might find useful.

Popular Tools

List of popular tools that users love and frequently use.

New Tools

The latest tools added to our collection, designed for you.

Topics

The tools grouped by topics to quickly find what you need.
Free online JSON to CSV converter. Paste or upload JSON data and get formatted CSV instantly — no upload, 100% private. Supports custom delimiters, UTF-8 BOM, and JSON code editor.

JSON To CSV

Free online JSON to CSV converter. Paste or upload JSON data and get formatted CSV instantly — no upload, 100% private. Supports custom delimiters, UTF-8 BOM, and JSON code editor.
Free online Excel to JSON converter. Transform XLSX, XLS, XLSM files into JSON arrays, objects, or keyed formats instantly in your browser — no upload, 100% private.

Excel To JSON

Free online Excel to JSON converter. Transform XLSX, XLS, XLSM files into JSON arrays, objects, or keyed formats instantly in your browser — no upload, 100% private.
Free Excel to CSV converter. Convert XLSX, XLS, XLSM to CSV instantly in your browser. No upload, 100% private. Edit, transpose, deduplicate before exporting.

Excel To CSV

Free Excel to CSV converter. Convert XLSX, XLS, XLSM to CSV instantly in your browser. No upload, 100% private. Edit, transpose, deduplicate before exporting.
Free online Excel to SQL converter. Generate CREATE TABLE and INSERT statements from spreadsheets for MySQL, PostgreSQL, SQLite, and SQL Server. Supports batch insert, primary keys, and type inference.

Excel To SQL

Free online Excel to SQL converter. Generate CREATE TABLE and INSERT statements from spreadsheets for MySQL, PostgreSQL, SQLite, and SQL Server. Supports batch insert, primary keys, and type inference.