Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3842422
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:47:29+00:00 2026-05-19T15:47:29+00:00

I want to know which is faster: XML and JSON? When to use which

  • 0

I want to know which is faster: XML and JSON?
When to use which one ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:47:29+00:00Added an answer on May 19, 2026 at 3:47 pm

    Before answering when to use which one, a little background:

    edit: I should mention that this comparison is really from the perspective of using them in a browser with JavaScript. It’s not the way either data format has to be used, and there are plenty of good parsers which will change the details to make what I’m saying not quite valid.

    JSON is both more compact and (in my view) more readable – in transmission it can be “faster” simply because less data is transferred.

    In parsing, it depends on your parser. A parser turning the code (be it JSON or XML) into a data structure (like a map) may benefit from the strict nature of XML (XML Schemas disambiguate the data structure nicely) – however in JSON the type of an item (String/Number/Nested JSON Object) can be inferred syntactically, e.g:

    myJSON = {"age" : 12,
              "name" : "Danielle"}
    

    The parser doesn’t need to be intelligent enough to realise that 12 represents a number, (and Danielle is a string like any other). So in javascript we can do:

    anObject = JSON.parse(myJSON);
    anObject.age === 12 // True
    anObject.name == "Danielle" // True
    anObject.age === "12" // False
    

    In XML we’d have to do something like the following:

    <person>
        <age>12</age>
        <name>Danielle</name>
    </person>
    

    (as an aside, this illustrates the point that XML is rather more verbose; a concern for data transmission). To use this data, we’d run it through a parser, then we’d have to call something like:

    myObject = parseThatXMLPlease();
    thePeople = myObject.getChildren("person");
    thePerson = thePeople[0];
    thePerson.getChildren("name")[0].value() == "Danielle" // True
    thePerson.getChildren("age")[0].value() == "12" // True
    

    Actually, a good parser might well type the age for you (on the other hand, you might well not want it to). What’s going on when we access this data is – instead of doing an attribute lookup like in the JSON example above – we’re doing a map lookup on the key name. It might be more intuitive to form the XML like this:

    <person name="Danielle" age="12" />
    

    But we’d still have to do map lookups to access our data:

    myObject = parseThatXMLPlease();
    age = myObject.getChildren("person")[0].getAttr("age");
    

    EDIT: Original:

    In most programming languages (not all, by any stretch) a map lookup such as this will be more costly than an attribute lookup (like we got above when we parsed the JSON).

    This is misleading: remember that in JavaScript (and other dynamic languages) there’s no difference between a map lookup and a field lookup. In fact, a field lookup is just a map lookup.

    If you want a really worthwhile comparison, the best is to benchmark it – do the benchmarks in the context where you plan to use the data.

    As I have been typing, Felix Kling has already put up a fairly succinct answer comparing them in terms of when to use each one, so I won’t go on any further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI, i need a XML parser. i want to know that which one is
Pretty straightforward, but I just want to know which is faster. I think simply
I want to know which of the 2 queries below is faster :- Select
first thing I want to know in between two algorithms which one is better
I want to know which tool can be used to measure the cyclomatic complexity
I want to know which *.config file the ConfigurationManager is using. How can I
I want to swap two integers, and I want to know which of these
i want to know how to edit a single row (which i select) from
I want to know if i can create a custom google maps application,on which
Want to know what the stackoverflow community feels about the various free and non-free

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.