jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Say hi →

JSON to Avro Schema

JSON sample → Avro record schema (.avsc) · updated 28 July 2026

Generate an Avro schema from a JSON sample. Objects become record types, arrays become array types, and optional fields become a ["null", T] union with a null default — the shape Kafka's schema registry needs for a backward-compatible field.

Paste input to start.

How to generate an Avro schema from JSON

  1. Paste a JSON sample — ideally an array of several records, so optional fields are detected.
  2. Set the Root type name. Nested objects are named after the key that holds them, singularised for arrays.
  3. Set a Namespace — Avro full names are namespace.Name, and a registry will usually expect one.
  4. Review the nullable unions: field order inside a union matters for defaults, and null must come first for a null default to be valid.
  5. Copy the code, or download it as a file.

Type mapping

Field names are converted to snake_case, since Avro names must match [A-Za-z_][A-Za-z0-9_]*. Where the JSON key differs, an aliases entry preserves it — that is also what lets a reader resolve data written under the old name.

Schema evolution rules to keep in mind

Getting good types out of a sample

Type inference from a sample is only as good as the sample. Three habits make the output far more useful:

Privacy

Nothing is uploaded. Inference and code generation run in this tab. No server sees the payload you paste — which matters, because real API responses tend to contain real user data.

FAQ

Why is my nullable field a union instead of just the type?

Avro has no separate nullability flag. A field that can be null is literally a union of null and the type, and null is listed first so "default": null is valid — Avro requires the default to match the union's first branch.

Can it emit logical types for timestamps?

Not automatically. An ISO 8601 string is a string as far as the sample shows. To get {"type": "long", "logicalType": "timestamp-millis"} you must also change the value to epoch millis on the producer side.

Is the output valid for Confluent Schema Registry?

The schema itself is valid Avro. The registry additionally enforces your subject's compatibility policy, so check a new version against the previous one before registering it.