-
Pl
chevron_right
ProcessOne: Stop Telling Us XMPP Should Use JSON
news.movim.eu / PlanetJabber • 15:14 • 3 minutes
We hear this too often: “XMPP uses XML. It should use JSON—it’s more modern.”
The logic seems straightforward: JSON came later, so it must be better. But better for what, exactly?
JSON became successful because it’s the standard serialization format for JavaScript. That made it convenient for browser-based applications.
Does that make it the universal format for every protocol? Of course not.
Consider this: browsers still use HTML to organize web pages, not JSON. Same with CSS. Why? Because using JSON for everything would be a nightmare.
XML remains the best format for representing trees—deep hierarchies of nested data. JSON handles flatter structures well, but good messaging protocols are extensible: extensions can be embedded at different levels and composed together, like Lego bricks. That’s where XML shines.
The Performance Myth
Another common claim: XMPP’s XML is more complex than JSON, so it must be much slower.
In practice, XMPP chat platforms are snappier, with remarkably low message latency. How?
XMPP clients don’t parse XML the way most people assume. They’re not building massive DOM trees in memory, like a browser loading a page. Instead, they use stream-based parsing—XML arrives, gets parsed incrementally, and converts directly into native data structures.
This is especially true in browser environments, where XMPP streams run over WebSockets, which naturally frames the XMPP protocol. That’s why you are never actually working with XML trees consuming large chunks of memory. Modern implementations like XMPP.js go further and use LTX—a lightweight parser built specifically for XMPP’s streaming model—rather than the browser’s DOM parser. The result: developers work with JSON-like objects anyway. The wire format becomes invisible to your application code.
XML brings three key advantages:
- Built-in extensibility with validation via XML Schemas
- Clean namespace management for XEPs: when the protocol needs to evolve, you can change the namespace of an extension, making versioning explicit and backward compatibility manageable
- 25+ years of mature tooling and battle-tested parsers
These matter when you’re building federated systems that need to evolve over time and need to stay compliant over time. The XMPP federation is a huge ecosystem of servers that can talk to each other, relying on different server implementations and are not always up to date. Still, the federation works, and we too often forget that this is a great achievement in itself.
Real performance bottlenecks in XMPP deployments come from elsewhere entirely: network latency, database optimization for roster and message storage, custom module performance, external components, or clustering and routing logic.
The myth persists because XML looks verbose when you read it. But visual verbosity has almost no correlation with parsing performance. Modern CPUs parse XML and JSON at nearly identical speeds for typical XMPP message sizes. Any difference vanishes in a real-world client.
Where the Real Complexity Lives
XMPP does have genuine complexity—but it’s not the wire format. It’s the protocol depth and the extensive XEP ecosystem with hundreds of extensions. That’s a real learning curve.
Consider XMPP when these factors matter to you:
- Federation across organizational boundaries
- Open standards and avoiding vendor lock-in
- Protocol stability that won’t break in three years
- Extensibility without forking the protocol
If those resonate, the wire format should be the least of your concerns.
We’ve been building XMPP systems for over 25 years. The XML performance question comes up often in early conversations. Every single time, we end up optimizing ejabberd configuration, clustering, architecture, client protocol usage, and databases instead.
Thinking about XMPP for your next project? Reach out during the design phase. We’ll help you avoid the actual bottlenecks.