JSON and XML both exist to structure and exchange data between systems, and for a long time XML was the clear default for this job. JSON has largely displaced it for new development since, mostly on the strength of being noticeably simpler to read and easier to work with in modern programming languages — a genuinely practical advantage, not just a matter of newer being fashionable.
XML: verbose, but rigorously structured
XML (Extensible Markup Language) represents data using opening and closing tags, similar in spirit to HTML — a piece of data gets wrapped in a named tag pair describing what it represents. This structure is thorough and rigorously definable (XML supports formal schemas that precisely specify what a valid document must contain), but it's also noticeably verbose — the repeated opening and closing tags add up to meaningfully more characters than the same data would take in JSON.
JSON: leaner syntax, native to JavaScript
JSON (JavaScript Object Notation) represents the same kind of structured data using a more compact syntax of curly braces, key-value pairs, and arrays — no repeated closing tags, generally less visual clutter for a human reading it, and less raw data to transmit for the same information. JSON also maps naturally onto data structures already built into JavaScript and most other modern programming languages, meaning code can typically parse JSON into a usable object with very little additional effort, which was a significant part of why it caught on so quickly once JavaScript-heavy web development took off.
Why JSON became the default for new development
Beyond the more compact syntax, JSON's straightforward mapping onto native data structures in most modern languages makes it simply easier and faster to work with in day-to-day development — less code needed to parse it, less visual noise when reading it directly, and a smaller payload size for the same underlying data. These are all genuinely practical advantages, which is why JSON became the default choice for most new APIs and data exchange formats, particularly anything web-related.
Where XML still holds ground
Some older systems, particular enterprise software, and certain industries with long-established XML-based standards (various document and data-interchange standards built up over decades) still rely on XML, partly due to its more rigorous schema-validation capabilities and partly due to simple legacy — enormous amounts of existing infrastructure were built around XML before JSON existed as an alternative, and migrating away from an established, working standard isn't always worth the disruption just because a newer format exists.
A practical way to decide
For new development, particularly anything web or JavaScript-related: JSON is the more practical, more common default today, and for good reason. For working with established legacy systems, certain enterprise contexts, or specific industries with entrenched XML-based standards: XML often remains the expected format simply because that's what the existing infrastructure and standards were already built around, independent of JSON's general advantages elsewhere.
If you're working with structured data that ultimately needs to become a readable document rather than machine-readable data, TXT to PDF can turn a formatted text export into a properly presented document once the data itself has been extracted or summarized into readable form.