XML to Objective-C Converter Online

Paste any XML and generate iOS Objective-C @interface NSObject classes with NSString *, NSInteger, and NSArray * properties. Attributes are flagged in source comments so your NSXMLParser delegate knows where each value lands — all in your browser.

What is an XML to Objective-C converter?

An XML to Objective-C converter takes a real XML document and emits @interface NSObject classes whose @property declarations mirror the XML element / attribute tree. The OpenFormatter generator inspects every element and attribute, infers Foundation types (NSString *, NSInteger, NSArray *), and produces a class hierarchy ready for NSXMLParser, RaptureXML, or KissXML — saving the tedious step of writing them by hand for SOAP, RSS, or plist-style XML.

XML differs from JSON in two ways your iOS model has to honour. First, XML has attributes on elements (<book id="bk101">) — these arrive in the attributeDict argument of parser:didStartElement: rather than as separate elements. Second, XML has namespaces; the generator strips them by default. The output flags attribute properties with an inline source comment so your NSXMLParserDelegate dispatch is unambiguous.

Sample XML and the Objective-C @interface it generates

Input XML

<book id="bk101" lang="en">
  <title>Effective Objective-C</title>
  <year>2013</year>
  <price currency="USD">39.99</price>
</book>

Generated Objective-C

#import <Foundation/Foundation.h>

@interface Price : NSObject
@property (nonatomic, strong) NSString *currency; // XML attribute
@property (nonatomic, assign) double text;        // text content
@end

@interface Book : NSObject
@property (nonatomic, strong) NSString *id;    // XML attribute
@property (nonatomic, strong) NSString *lang;  // XML attribute
@property (nonatomic, strong) NSString *title; // <title>
@property (nonatomic, assign) NSInteger year;  // <year>
@property (nonatomic, strong) Price *price;    // <price>
@end

Notice id and lang are flagged as XML attributes, while title and year are child elements. The nested <price currency="USD">39.99</price> generates a Price @interface with one attribute property and one text-content property — exactly what NSXMLParser populates.

How to convert XML to Objective-C — 4 steps

  1. Paste your XML. A SOAP envelope body, an RSS feed entry, a plist — anything well-formed.
  2. Click Convert. The browser parses the XML and generates @interface classes for the full element tree.
  3. Review attribute properties. Confirm comment-tagged attribute properties match what you expect; switch strong to copy for NSString * if you prefer Cocoa convention.
  4. Drop into your Xcode project. Copy the output, save each @interface as its own .h file, and wire up an NSXMLParserDelegate to populate the model.

Foundation Types

Every @property uses NSString *, NSInteger, BOOL, double, or NSArray * — the canonical Foundation types every Cocoa developer recognises on sight.

Attribute vs Element

XML attributes and child elements both become @property declarations, but attributes carry an inline comment so your NSXMLParser delegate knows which event populates them.

Client-Side Only

Your XML — including SOAP responses with credentials — is parsed in JavaScript on your machine. Verify in DevTools: zero network requests on Convert.

Common use cases

  • check_circleGenerate Objective-C model classes from a SOAP service response
  • check_circleBuild iOS @interface types for an RSS or Atom feed reader
  • check_circleConvert plist XML to typed NSObject classes
  • check_circleGenerate Objective-C types from an XSD-described XML file
  • check_circleCreate iOS unmarshalling models for legacy enterprise XML
  • check_circleBuild typed @interface for a SAML or WS-Security XML payload
  • check_circleGenerate Objective-C models for sitemap.xml or robots.xml
  • check_circleCreate Foundation classes for legacy iOS apps interoperating with .NET XML services

Why client-side conversion matters

SOAP responses and enterprise XML often contain customer PII, API tokens, internal endpoint names, and database identifiers. Pasting them into a server-hosted converter is a compliance violation in most regulated industries. OpenFormatter parses the XML and generates Objective-C source entirely in JavaScript on your device — no upload, no logs, no cookies. Open DevTools → Network and confirm no requests fire when you click Convert.

More XML tooling

Validate, format, or convert XML to other languages — every tool runs locally in your browser.

Frequently Asked Questions

How are XML attributes mapped to Objective-C properties?

XML attributes (e.g. <book id="bk101">) and child elements both become @property declarations on the generated @interface, but attributes are tagged with a "// XML attribute" comment so the source code clearly distinguishes them. When you wire up NSXMLParser, attributes arrive in the attributeDict argument of parser:didStartElement: while elements arrive as separate didStartElement events — your parser delegate uses the comment as a hint for which dispatch path populates each property.

iOS NSXMLParser vs RaptureXML — which should I use?

NSXMLParser ships with Foundation, has no third-party dependency, and is event-based (SAX-style) — ideal for large XML and CPU/memory-constrained iOS apps. RaptureXML and KissXML wrap libxml2 with an XPath / DOM API that is easier for ad-hoc scraping but pulls in extra binary weight. The generated classes work identically for either: NSXMLParser populates them via delegate callbacks, RaptureXML populates them via [element child:@"title"].

Should properties be strong, weak, or copy?

The generator emits "nonatomic, strong" for object types (NSString *, NSArray *, custom @interface *) and "nonatomic, assign" for scalars (NSInteger, BOOL, double). For NSString * you can switch to "copy" if the XML source mutates strings before they are stored — copy is the conservative iOS convention for value-like immutable types.

How are repeated child elements like <tag> represented?

Repeated children become a single NSArray * property. The generator does not emit NSArray<TagType *> * (Objective-C lightweight generics) by default — append a generic if you want compile-time type checks: @property (nonatomic, strong) NSArray<Tag *> *tags;. Lightweight generics are erased at runtime so they have zero perf cost.

Does the output use ARC?

Yes. The generated @interface assumes Automatic Reference Counting — there are no manual retain / release calls and "strong" is the ARC ownership qualifier. ARC has been the iOS / macOS default since iOS 5 and Xcode 4.2, so this matches every modern Cocoa Touch project.

What about Swift interop?

The generated classes are bridge-friendly — NSString *, NSArray *, NSInteger, and BOOL all bridge to Swift String, [Any], Int, and Bool. Add @objc on the @interface (or expose it via the Bridging-Header.h) and Swift can call any property directly. Mixed projects often use Objective-C XML model classes plus Swift business logic.

Is the XML I paste sent to your servers?

No. XML is parsed by the browser DOMParser and the Objective-C source is generated entirely in JavaScript on your machine. Open DevTools → Network and you will see no requests when you click Convert. Safe for SOAP responses and configuration files containing API keys or credentials.

How do I parse XML into the generated @interface?

Use NSXMLParser with a delegate that populates the model: implement parser:didStartElement:namespaceURI:qualifiedName:attributes: to capture attributes into the matching @property, parser:foundCharacters: to accumulate text content, and parser:didEndElement: to commit the value. For simpler one-off scripts, RaptureXML lets you write [book child:@"title"].text in one line.

XML to Objective-C Converter Online — Free