JSON to Apex

Paste a JSON response and get Apex wrapper classes, a parse() method and a test class — ready for your integration.

Runs in your browser — nothing you paste is sent to us or stored.

How to use it

  1. 1

    Paste the JSON

    A real response from the API you’re calling works best — every field and list that can appear should be in it.

  2. 2

    Name the class

    Pick the outer class name. Nested objects become inner classes named after their keys; identical shapes share one class.

  3. 3

    Copy both classes

    Copy or download the wrapper class and its test class, then call YourClass.parse(response.getBody()).

Questions

How do I use the generated class?

After an HTTP callout, pass the body to the static parse method: OrderResponse r = OrderResponse.parse(res.getBody()); then read fields like r.customer.name or loop over r.items. parse() uses System.JSON.deserialize, which fills the fields by name and ignores keys the class doesn’t have.

Why are some keys renamed?

Apex field names must be valid identifiers and can’t be reserved words like number, date or limit — and Apex ignores case, so “id” and “Id” would clash. Such keys get a new name (number → number_x), and parse() renames them in the JSON text before deserializing. If a value in your data could contain the same "key": text, switch to JSONParser for that class.

Why are null values and empty lists typed as String?

A sample can’t show what type a null or an empty list will hold, and JSON.deserialize can’t fill fields typed Object. The tool uses String (or List<String>) and lists every such field under the code, so you can set the real type.

What about dates?

Text that looks like a date or date-time stays a String, with a comment. If the API sends ISO 8601 values (2026-10-22 or 2026-10-22T10:00:00Z), you can change the type to Date or Datetime and JSON.deserialize will parse them.

Does the test class give me code coverage?

It parses your sample through parse(), which covers the class — wrapper fields need no coverage of their own. Add assertions on the values your code relies on, and test your callout with HttpCalloutMock separately.

Is my JSON sent anywhere?

No. The classes are generated in your browser — useful when the sample contains real customer data. Still, strip personal data from samples you keep in test classes.

Further reading

Want to go beyond the tools?

Learn Salesforce development — live classes with people who build on Salesforce every day.

See the learning path →