Home JSON to classes

JSON to classes

Builds Python, Java, Kotlin, and C# classes. A blank name becomes RootObject.

Language

Classes

Getters and annotations are not generated. Order / apple / A1 / BaseModel / List.

Why this exists

Copying a sample response into class fields drifts as the fields grow. Pasting it produces Item and List at once.

The conversion finishes in this browser. The JSON is not sent to a server.

  1. 01How to use it

    Order / apple / A1 / RootObject.

    Python BaseModel. Java. Kotlin. C#. List. user-id.

  2. 02What you get

    data class Item / data class Order / List<Item> / sku A1 / apple.

    BaseModel / RootObject / user-id → user_id.

    EnteredOrder apple A1

    Order apple
    A1 Item
    BaseModel List
    RootObject user-id
  3. 03Worth knowing

    user-id becomes user_id. RootObject is the blank name.

    List holds the nested objects. BaseModel is the Python base. Order, apple, A1.

Questions

QOrder?
AOrder, apple, A1, Item, List.
QBaseModel?
APython BaseModel. Java fields. Kotlin data class. C# get; set;.
QRootObject?
ABlank root name → RootObject.
Quser-id?
Auser-id → user_id.

How this page works it out

Pasting JSON produces a Python BaseModel, Java fields, a Kotlin data class, and C# properties. With the root name Order, apple and an items entry A1 become an Item class and a List. A blank name becomes RootObject.

A key such as user-id becomes user_id, and the original key stays in a comment or a Field alias. Integers become long or Long, and fractions become double. An empty object or an array of bare numbers does not become classes.

The conversion finishes in this browser. Getters and annotations are not added. Objects of the same shape reuse one class.

  • # Order
  • # BaseModel
  • # List
  • # RootObject