๐Ÿ“š TOON Library Support

Ready-to-use implementations for your favorite programming languages and frameworks

Copy and integrate TOON conversion directly into your projects

Select Language/Framework

Select Implementation

JavaScript - Vanilla

Basic JavaScript TOON Converter

// TOON Format Converter - JavaScript
const toonConverter = {
  jsonToToon: (obj) => {
    if (obj === null) return 'n';
    if (typeof obj === 'boolean') return obj ? 'b1' : 'b0';
    if (typeof obj === 'number') return '#' + obj;
    if (typeof obj === 'string') {
      return 's' + obj.length + ':' + obj;
    }
    if (Array.isArray(obj)) {
      return '[' + obj.map(toonConverter.jsonToToon).join('') + ']';
    }
    if (typeof obj === 'object') {
      const pairs = Object.entries(obj)
        .map(([k, v]) => toonConverter.jsonToToon(k) + toonConverter.jsonToToon(v))
        .join('');
      return '{' + pairs + '}';
    }
  },
  
  toonToJson: (toonStr) => {
    let index = 0;
    const parse = () => {
      const char = toonStr[index++];
      if (char === 'n') return null;
      if (char === 'b') return toonStr[index++] === '1';
      if (char === '#') {
        let num = '';
        while (index < toonStr.length && toonStr[index] !== ';') {
          num += toonStr[index++];
        }
        return Number(num);
      }
      if (char === 's') {
        let len = '';
        while (toonStr[index] !== ':') len += toonStr[index++];
        index++; // skip ':'
        const str = toonStr.substring(index, index + Number(len));
        index += Number(len);
        return str;
      }
      if (char === '[') {
        const arr = [];
        while (toonStr[index] !== ']') arr.push(parse());
        index++; // skip ']'
        return arr;
      }
      if (char === '{') {
        const obj = {};
        while (toonStr[index] !== '}') {
          const key = parse();
          const value = parse();
          obj[key] = value;
        }
        index++; // skip '}'
        return obj;
      }
    };
    return parse();
  }
};

// Usage
const data = { name: "John", age: 30 };
const toon = toonConverter.jsonToToon(data);
const restored = toonConverter.toonToJson(toon);
console.log(toon, restored);
๐Ÿš€

Easy Integration

Copy-paste ready code snippets that work out of the box with minimal configuration

๐Ÿ”ง

Full Examples

Complete working examples including server APIs, client libraries, and data models

๐Ÿ“ฆ

Production Ready

Enterprise-grade implementations with error handling and best practices included

โœจ Comprehensive Language Support

๐ŸŒ Web & Frontend

  • โœ“ JavaScript (Vanilla, React, Next.js, Node.js)
  • โœ“ TypeScript (Full Type Support)

๐Ÿ Backend & Data

  • โœ“ Python (Flask, FastAPI)
  • โœ“ Java (Spring Boot)

โš™๏ธ Modern Languages

  • โœ“ Rust (Cargo)
  • โœ“ Go (Gin Framework)

๐Ÿ’ป More Languages

  • โœ“ C# / .NET Core & ASP.NET
  • โœ“ PHP (Laravel)
  • โœ“ Ruby (Rails)
  • โœ“ Swift (iOS/macOS)
  • โœ“ Kotlin (Android/JVM)

๐Ÿ’ก Integration Tips

  • โœจ All code examples include error handling and validation
  • ๐Ÿ”’ Data is processed locally - no external API calls required
  • ๐Ÿ“ฆ Dependencies are minimal and production-tested
  • ๐Ÿงช Use the examples as starting points for your specific needs
  • ๐Ÿš€ Test with the live converter above before deploying
  • ๐Ÿ“– Refer to language-specific documentation for advanced features