JSON vs. Markdown vs. YAML: Which Format Uses Fewer LLM Tokens?
Every curly brace, quotation mark, colon, and indentation space in your API payload costs tokens. When passing 50 product records or CRM rows into a prompt, pretty-printed JSON silently wastes 25% to 40% of your input token budget on punctuation and repeated key names.
Token Efficiency by Data Format (50-Row Sample)
| Format | Relative Token Count | Best Use Case |
|---|---|---|
| Pretty-printed JSON (2-space indent) | 100% (Baseline) | Human debugging only |
| Minified JSON (no whitespace) | ~82% | Strict API output schemas |
| YAML | ~76% | Nested config & instructions |
| Markdown Table / CSV | ~62% – 68% | Tabular records passed as prompt input |
Best Practice: Asymmetric Formatting
Use Markdown tables or compact CSV when feeding context into the model (because keys appear once in the header row instead of repeating 50 times), and only request minified JSON in the output when downstream code needs strict parsing. Test your own payload shapes in our Token Counter.