JSON to Apex
Converts a JSON object or array into typed Salesforce Apex class definitions, correctly mapping strings, integers, doubles, booleans, and nested objects to their Apex equivalents. Options let you toggle @AuraEnabled annotations for Lightning components and include ready-made JSON.deserialize / JSON.serialize helper methods. The conversion runs in your browser and produces a .cls file you can download immediately.
JSON
Class Name
Code Options
Apex Code
What is JSON to Apex Converter?
Salesforce integrations always involve JSON — REST callouts return it, Platform Events carry it, and external webhook payloads arrive as it. But Apex's type system requires explicit class definitions to deserialise JSON with JSON.deserialize(). Writing those classes for every integration point is repetitive work that this tool automates. Paste your JSON payload and get a set of Apex class definitions with public properties, correct Apex types (String, Integer, Decimal, Boolean, List<T>), and a static parse() method. Nested objects become inner classes. The output is formatted for Salesforce Apex syntax and is immediately deployable via Developer Console, VS Code with Salesforce Extensions, or SFDX. Compatible with @RestResource endpoints, trigger handler patterns, and Queueable Apex jobs.
How to Use
- 1
Paste Your JSON
Paste a JSON object or array representing a Salesforce API response, platform event, or external API payload. The tool generates Apex classes compatible with JSON.deserialize().
- 2
Configure Apex Class Options
Set the outer class name, choose whether to generate inner classes or standalone classes, and select whether to add a static parse() method using JSON.deserialize() for convenient one-line deserialisation.
- 3
Generate Apex Classes
Click "Generate Apex". Salesforce Apex types are inferred: String, Integer, Decimal, Boolean, List<T>. Each nested JSON object becomes an inner class or a separate Apex class with public properties.
- 4
Deploy to Salesforce
Copy the generated Apex class into your Salesforce org via Developer Console, VS Code with Salesforce CLI, or SFDX. Use JSON.deserialize(jsonString, Root.class) in your trigger or flow to parse the JSON payload.
Common Use Cases
Salesforce Integration Wrappers
Generate Apex wrapper classes from external REST API response JSON to deserialise incoming payloads in Salesforce integration flows, eliminating manual class definition for each API endpoint.
Salesforce REST Callout Models
Create typed Apex classes for outbound REST callout response parsing. Use JSON.deserialize() with the generated class to safely access API response fields in Apex triggers and flows.
Platform Event & Streaming Models
Scaffold Apex classes from Platform Event or Change Data Capture JSON payloads to handle Salesforce streaming API messages with type-safe field access in subscriber code.
Lightning Component Data Models
Generate Apex inner classes or standalone classes from the JSON data shapes expected by Lightning Web Components, ensuring consistent data contracts between Apex controllers and LWC JavaScript.
Conversion Examples
JSON Object → Apex Class
A JSON object generates an Apex class usable with JSON.deserialize().
Input JSON
{
"id": "001xx000003GYk1",
"name": "Acme Corp",
"annualRevenue": 1500000,
"isActive": true
}Output CSV
public class Root {
public String id { get; set; }
public String name { get; set; }
public Decimal annualRevenue { get; set; }
public Boolean isActive { get; set; }
public static Root parse(String json) {
return (Root) JSON.deserialize(json, Root.class);
}
}Nested JSON → Nested Apex Classes
Nested objects generate inner Apex classes with typed references.
Input JSON
{
"account": {"id": "001xx", "name": "Acme"},
"contacts": [{"id": "003xx", "email": "alice@acme.com"}]
}Output CSV
public class Root {
public Account account { get; set; }
public List<Contact> contacts { get; set; }
public class Account {
public String id { get; set; }
public String name { get; set; }
}
public class Contact {
public String id { get; set; }
public String email { get; set; }
}
}