Halodoc
Read post

Reducing LLM Token Costs by 15% by Switching from JSON to TOON Format

Halodoc reduced LLM API costs by 5–15% by switching from JSON to TOON (Token-Oriented Object Notation) for structured data in prompts. TOON eliminates JSON's syntactic overhead — braces, quoted keys, commas — and represents arrays of objects as CSV-style tables, cutting repeated key names. Evaluated against MessagePack, Protocol Buffers, and YAML, TOON offered the best balance of token efficiency (~35–45% theoretical reduction on structured data), LLM compatibility (~95% across OpenAI, Anthropic, Google, AWS Bedrock), and low integration effort. A shared Python SDK with JSON↔TOON converters was built, with config flags enabling per-use-case rollout and instant rollback. Output token optimization (tested at 8–43% reduction in POC) was not yet deployed to production. The post also covers complementary strategies: response caching with DynamoDB and batch API processing.

    #python#prompt-engineering
Jun 12•16m read time•From blogs.halodoc.io
Post cover image
Table of contents
IntroductionThe Challenge: JSON's Hidden Token TaxWhy TOON? Alternatives We ConsideredWhat is TOON?Evaluating TOON: Pre-Migration AnalysisWhere TOON Helps (and Where It Doesn't)Building the SDK: JSON ↔ TOON ConvertersMigrations in PracticePractical Advice for Adopting TOONBeyond TOON: Other LLM Cost OptimisationsConclusionReferencesJoin usAbout Halodoc
35.6K Impressions
Halodoc's image
Halodoc

HaloDoc is a healthcare technology platform that offers telemedicine services, online pharmacy, and ...

61 Followers

•

678 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard