Paste a JSON sample and get clean Objective-C @interface classes — nested objects become their own classes, arrays become typed NSArray properties, and each key becomes a @property. Fast, secure, and entirely in your browser.
No installation, no signup. Results in milliseconds.
A JSON to Objective-C converter reads a sample of JSON and writes the model classes that describe its shape: an @interface per object, with a @property declaration for each key. Instead of hand-writing a header for every API response, you paste the response and get Foundation-typed classes for your iOS or macOS app.
Objective-C model objects are plain NSObject subclasses with properties, and writing the header for a large payload by hand is tedious, especially choosing the right Foundation type and property attribute for each key. Generating it from a real sample gets the types and attributes right.
@interface per object, each nested object its own class.NSString, NSNumber, typed NSArray.copy for strings and arrays, strong for everything else.@class forward declarations for nested classes.These are the inference rules the converter applies so the output is predictable.
| JSON | Becomes in Objective-C |
|---|---|
Object { } | An @interface subclassing NSObject. |
| Nested object | Its own named class, forward-declared and referenced from the parent. |
Array [ ] | A typed NSArray<Item *> or NSArray<NSString *>. |
| Number | NSNumber (read with intValue / doubleValue). |
| Boolean | NSNumber (read with boolValue). |
| string | NSString. |
| null only / mixed types | id (or NSArray<id> for a mixed array). |
Numbers and booleans both become NSNumber, because NSJSONSerialization decodes them that way; you read the underlying value with intValue, doubleValue, or boolValue. NSString and NSArray properties use copy (the convention for value-like objects), everything else uses strong, and a key that clashes with a reserved word like id or description is renamed to a safe property such as theId. Validate the JSON first with the JSON parser if it will not convert, or tidy it in the JSON formatter.
idA field that is only ever null, an empty array, or holds more than one unrelated type has no single Foundation type, so it falls back to id. Paste a representative sample with those fields populated to get precise types, and give an array of several records so every key is seen. For a deeply nested payload, expanding it in the JSON viewer first helps you confirm the shape.
See how a nested object with an array of items becomes clean Objective-C headers.
Notice three things: items became its own Item class and a typed NSArray<Item *>, total is an NSNumber (you read it with doubleValue), and the reserved key id became the safe property theId. For the step-by-step reasoning, see our guide on converting JSON to Objective-C classes.
Typed model classes from real data, in seconds.
Everything developers ask about generating Objective-C classes from JSON.
NSString, numbers and booleans become NSNumber, objects become their own class pointer, and arrays become a typed NSArray such as NSArray<Item *>. A null-only or mixed field becomes id.NSJSONSerialization decodes every JSON number and boolean into an NSNumber, so the model properties use NSNumber to match what you actually receive. You read the value with intValue, doubleValue, or boolValue.NSString and NSArray properties use copy, the Objective-C convention for value-like objects, and everything else uses strong. All properties are nonatomic, as model objects usually are.theId or theDescription. You map the property back to the JSON key in your parsing layer.@class and referenced from the parent, and arrays become typed NSArray properties with the element type inferred from the items.NSJSONSerialization into an NSDictionary, then assign each value to the matching property, or use a mapping library such as Mantle or JSONModel to bind the dictionary to your @interface automatically.Hands-on articles from our blog.
All free, all browser-based, no signup required.