Home » Java » Enterprise Java » JSON and XML: How Do They Compare?

About Evan Glazer

Evan Glazer
Evan Glazer is a software engineer and self-starter at Edukate, where he uses Ember and Ruby on Rails and works with natural language processing and machine learning.

JSON and XML: How Do They Compare?

JSON and XML: How Do They Compare?

JSON and XML are two human-readable text formats that have emerged as rivals over the years. XML’s purpose is storing and defining documents and data through the optional use of a schema. JSON was almost the exact opposite – a serialization format with requirements so simple they fit on the back of a credit card. But, when should you use one or the other? We have to take into account that XML and JSON have similarities and differences that can affect your application’s performance. In this article, we will outline what’s going on, and what you need to know about JSON and XML.


JavaScript caused a seismic shift in web development with the creation of Node (which is really server-side JavaScript). Everything from this point on got replaced with REST APIs and JSON. JSON became the most efficient data structure standard in web apps. Web 1.0 was hindered with parsing data structures and caused innovation to slow down, while Web 2.0 created an explosion in productivity and Moore’s Law kicked in. JavaScript, which was considered a dead language at one point, was revived and is now one of the most popular languages in 2019.

Comparing JSON and XML


  • Both are human readable.
  • Both are hierarchal with a values within values format.
  • Both can be parsed and used by a number of languages.



  • Shorter
  • Quicker to parse
  • Uses arrays
  • Parsed by a standard JavaScript function
  • Data interchange format


  • Needs an XML parser.
  • Longer to parse.
  • Doesn’t use Arrays!!

Which should I consider?

Everyone has their own opinion about JSON and XML. As a developer, I more or less stick to JSON in my projects unless an API requires XML parsing.

XML is still being used actively in web publishing to create interactive pages. It’s also used for searching the web, metadata and pervasive computing, which is another way to say wireless devices, like cell phones.

Depending on the type of application, it will vary based on what best fits your application to access information.

What’s going on

As applications and platforms evolved, efficiency and performance have been the status quo in priority. APIs evolved over the years to become leaner, and JSON has overtaken XML as the preferred format among developers and technology stacks.

Additional resources

Published on Java Code Geeks with permission by Evan Glazer, partner at our JCG program. See the original article here: JSON and XML: How Do They Compare?

Opinions expressed by Java Code Geeks contributors are their own.

(+1 rating, 1 votes)
You need to be a registered member to rate this.
1 Comment Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Alexandros Ioannidis Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

newest oldest most voted
Notify of
Alexandros Ioannidis
Alexandros Ioannidis

Great article! Although I’ll admit I prefer the usage of XML mainly as an external mechanism to change the parameters of any Java/Python project of mine. Furthermore, XML Schemata are a standard used extensively for expressing Ontologies in the Web and for describing the structure and semantics of Web documents accurately.