XML to TOON Converter

Input XML

Output TOON

Your TOON appears here as you type.

users[3]{id,name,role}:
  1,Alice,admin
  2,Bob,user
  3,Cleo,user
Field names once, then one row per record.

Paste data to see token savings

Convert XML to TOON with our free online converter.

Example: XML input and real TOON 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>
TOON output (167 characters)
catalog:
  book[2]{title,author,year,"@_id"}:
    Designing Data-Intensive Applications,Martin Kleppmann,2017,bk101
    The Pragmatic Programmer,Andrew Hunt,1999,bk102

TOON output is 44% 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). Across larger datasets, TOON averages about 43% fewer tokens than JSON (42.6%) according to the official TOON benchmark.

XML to TOON: what changes

  • Repeated XML elements with the same children become a TOON table, which is where XML-to-TOON saves the most. The @_id attribute key is quoted because it starts with @.
  • 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 TOON: TOON saves the most on arrays of objects that share the same fields: they collapse into one header plus one row per record. Nested or non-uniform objects are written as indented key: value lines and save much less.

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 TOON

TOON (Token-Oriented Object Notation) is an indentation-based format designed for LLM prompts. It uses about 43% fewer tokens than JSON on average (42.6% in the official TOON v4.1 benchmark), ranging from about 33% on mixed/nested structures to about 59% on flat uniform tables.

  • ✓About 43% fewer tokens than JSON on average
  • ✓Tabular rows for uniform arrays
  • ✓Lossless round trip to JSON
  • ✓Readable without tooling
Full TOON Documentation →

Why Convert XML to TOON?

Use TOON when building LLM-powered applications, optimizing API costs, or when you need compact, readable data for AI models.

XML to TOON: Frequently Asked Questions

How do I convert XML to TOON?

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

Is the XML to TOON converter free?

Yes. Converting XML to TOON 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 TOON?

Convert XML to TOON with our free online converter.

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

Repeated XML elements with the same children become a TOON table, which is where XML-to-TOON saves the most. The @_id attribute key is quoted because it starts with @.

Is my data safe when I convert XML to TOON?

Yes. The XML to TOON 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.