Payload format optimizer
Convert JSON or CSV to minified JSON, YAML, CSV, a Markdown table or XML in your browser, and see which format costs the fewest tokens.
What it does
Paste the data you put in prompts — JSON, or CSV with a header row. The tool writes the same data in six formats: indented JSON, minified JSON, YAML, CSV, a Markdown table and XML. For the model you choose, it shows:
- how many tokens each format is, against the data as you pasted it;
- what the input costs over the number of requests you give;
- how much each format saves, or costs more;
- what each format keeps and what it loses.
Every conversion happens in your browser, with no library downloaded for it, and the data is not sent anywhere.
How it counts
Each format is counted with the chosen model's tokenizer — exact for OpenAI's models, whose tokenizer runs in your browser, and an estimate (characters ÷ 4) for the others, marked as one. With an estimate, the differences between formats are differences in length only. Each request is priced as if the payload were its whole input, by Salyro's own cost arithmetic on today's price list. The totals are exact multiples of that one request.
What each format keeps
- Minified JSON keeps everything and drops the whitespace. Usually the cheapest format that loses nothing.
- YAML keeps levels and types, and carries its structure in indentation. Strings that YAML could read as something else —
yes,null,0755,12:30— are quoted, so every YAML reader gets back the same values. - CSV and Markdown tables exist only for a list of records. A nested value is written into its cell as JSON text, and every value becomes text: a number and a string of digits look the same.
- XML keeps the levels and loses the types. Every name is written twice, in the opening and the closing tag.
What it does not know
- How well a model reads each format. Fewer tokens is cheaper; whether the model understands the data as well is for your own evaluation.
- The rest of the prompt and the answer: only the payload is counted.
FAQ
Why not always use CSV?
For flat records it is often the cheapest. But it cannot hold nested data or types, and a model has to know what each column means from the header alone.
Why does YAML sometimes cost more than JSON?
Indentation is tokens, and values YAML would misread must be quoted. For data with many short values, minified JSON can come out ahead.
Why is YAML written without a library?
The tool only writes YAML, it never reads it. A small writer does that in a page of code, instead of downloading a YAML library the page does not need. It was checked against three YAML parsers while it was written, and the tests keep those cases.
Sources
Token counts use OpenAI's encodings, tested against tiktoken. Which encoding each model uses is Reference Data; prices come from Salyro's model catalogue.
Where the numbers come from
- Model and pricing data is a snapshot of the catalogue Salyro itself uses, taken when this site was built.
- Facts about models and providers that are not in that catalogue carry their own source and the date they were checked, and are shown as unknown where no reliable source exists.
