XML to TONL Converter

Input XML

Output TONL

Your TONL appears here as you type.

Paste data to see token savings

Convert XML to TONL with our free online converter.

Example: XML input and real TONL output

The output below was generated by the same conversion code the converter uses, run on this sample when the page was built.

XML input (296 characters)
<catalog>
  <book id="bk101">
    <title>Designing Data-Intensive Applications</title>
    <author>Martin Kleppmann</author>
    <year>2017</year>
  </book>
  <book id="bk102">
    <title>The Pragmatic Programmer</title>
    <author>Andrew Hunt</author>
    <year>1999</year>
  </book>
</catalog>
TONL output (192 characters)
#version 1.0
root:
  catalog:
    book[2]{@_id,author,title,year}:
      bk101,Martin Kleppmann,Designing Data-Intensive Applications,2017
      bk102,Andrew Hunt,The Pragmatic Programmer,1999

TONL output is 35% smaller than the XML input. The same data is 214 characters as minified JSON and 341 as pretty-printed JSON. Sizes are character counts, not tokens: token counts depend on the model's tokenizer (see the tokenizer comparison).

XML to TONL: what changes

  • Reading XML: Attributes are kept with an @_ prefix (id="bk101" becomes "@_id"), repeated child elements become arrays, and numeric text becomes numbers. A single child element becomes an object, not a one-item array, so the shape depends on how many elements appear.
  • Writing TONL: TONL output starts with #version 1.0 and a root key, lists field names in braces, and sorts keys alphabetically. On small payloads the header and per-object field lists make it larger than TOON; TONL earns its place through its query, schema, and streaming tooling.

About XML

Extensible Markup Language is a verbose but powerful format. Still widely used in legacy systems, SOAP APIs, and document formats.

  • ✓Rich metadata
  • ✓Namespaces
  • ✓Validation schemas
  • ✓Legacy support
Full XML Documentation →

About TONL

TONL (Token-Optimized Notation Language) is a compact text format that maps one-to-one to JSON and ships with a query API, schema validation, and streaming. Savings are roughly 32-45% versus JSON in the TONL project's own measurements.

  • ✓Lossless round trip to JSON
  • ✓Query and aggregation API
  • ✓Schema validation (TSL)
  • ✓Streaming for large files
Full TONL Documentation →

Why Convert XML to TONL?

Use TONL when you want a compact text format plus tooling around it: querying, schema validation, or streaming. For plain prompt compression, TOON is usually the simpler choice.

XML to TONL: Frequently Asked Questions

How do I convert XML to TONL?

Paste your XML into the editor on json2toon.co. The tool detects the input and produces TONL instantly, then you copy the result. Conversion runs entirely in your browser, so nothing is uploaded to a server.

Is the XML to TONL converter free?

Yes. Converting XML to TONL on json2toon.co is free with no account, signup, or usage limit. A free public API is also available for automated, programmatic conversion.

Why convert XML to TONL?

Convert XML to TONL with our free online converter.

What should I watch out for when converting XML to TONL?

TONL output starts with #version 1.0 and a root key, lists field names in braces, and sorts keys alphabetically. On small payloads the header and per-object field lists make it larger than TOON; TONL earns its place through its query, schema, and streaming tooling.

Is my data safe when I convert XML to TONL?

Yes. The XML to TONL conversion happens client-side in your browser. Your source data stays on your device and is never sent to or stored on a server, which makes it safe for private or sensitive payloads.