When I explore the metadata from Salesforce page layouts, workflows or objects via an IDE, the metadata is all in XML format.

Why is this? Why would the metadata not be in JSON, for example? Is XML the default format for Salesforce metadata because that is what was mainstream at the time?


XML stands for EXtensible Markup Language and was designed to describe data. XML is a software and hardware-independent tool for carrying information. XML was designed to describe data, with focus on what data is. Standards for it became a W3C Recommendation in Feb of 1998. XML language has no predefined tags, you invent your own to describe your data. Because of that, XML separates data from HTML. It simplifies data sharing because its stored as plain text. For the same reasons, data transport is also simplified. XML documents form a tree structure and have a schema. XML has strict standards while JSON standards are not as strict (end tags are not required with JSON).

JSON is an acronym for JavaScript Object Notation and was originally created by Douglass Crockett as a syntax for storing and exchanging data when using JavaScript. The JSON format is syntactically identical to the code for creating JavaScript objects. Because of this similarity, instead of using a parser (like XML does), a JavaScript program can use standard JavaScript functions to convert JSON data into native JavaScript objects. Tor those reasons it's considered an "easier-to-use" alternative to XML by many.

Main differences between JSON and XML:

  • JSON doesn't use end tags, thus has no Document Schema like XML
  • JSON is shorter
  • JSON is quicker to read and write
  • JSON can use arrays
  • XML has to be parsed with an XML parser, JSON can be parsed by a standard JavaScript function.
  • For AJAX applications, JSON is faster and easier than XML

For further information, here are links to tutorials on XML and JSON at w3schools.com.


I realize I didn't specifically answer your question. The most important reasons among many are highlighted above in bold. For Salesforce to use it as a metadata language, it would need to support a schema, something that JSON does not do. Thus one of the reasons that XML is a better choice. It's well defined structure that requires opening and closing end tags is superior for transferring metadata without errors. That's also one of the reasons it's used for SOAP.

Some might say that XML is the "gold standard" and JSON is a relatively "quick & dirty" (sic) shortcut method that is adequately secure for a large number of use cases. Its my understanding there are also many variants on how JSON is implemented which can further complicate the use of JSON. However, that discussion is beyond the scope of this answer and my knowledge.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.