Instant JSON to Apex Converter for Salesforce Developers

Generate Apex classes and tests in seconds. Paste your JSON below!

✓ Valid JSON
Size: 0.2KB | Lines: 1
Apex Generator Active
WrapperClass.cls

How to Use json2apex

  1. Click the Settings icon (⚙) in the toolbar to change the Apex Class Name or disable parsing methods.
  2. Paste your JSON input directly or upload a JSON file (📂) in the toolbar.
  3. Your Apex wrapper class and test classes are automatically generated on the fly.
  4. Toggle between Apex Class and Test Class tabs in the output pane.
  5. Download your classes as a ZIP (📦) or download individually. Copy code to clipboard (📋) with a single click.

Key Features

Salesforce Integration Guide: Apex Wrapper Classes

When building integrations in Salesforce, developers must deserialize JSON payloads returned from web callouts. Using statically typed wrapper classes is the recommended best practice. This approach provides compile-time safety, autocomplete support, and self-documenting code contracts.

With json2apex.com, you can automate this boilerplate generation. Simply paste your JSON, specify the class name, and the tool builds the complete parser class alongside a corresponding unit test class with assertions to verify correct serialization/deserialization.

Handling Salesforce Reserved Keywords

Apex has reserved keywords (such as class, public, private, or limit) which cannot be used as variable names. If your payload uses these keys, json2apex automatically sanitizes the Apex properties by prefixing them with an underscore (e.g. _class) to prevent compiler failures.

Avoiding Common JSON_PARSER_ERRORs

One of the most common issues during deployment is the "JSON_PARSER_ERROR: Expected Array, Got Object". This happens when the API schema dynamically changes. Statically declared decimal values and list wrappers prevent mismatch exceptions. Always verify your mappings in sandbox environments first.